随笔分类 -  Algorithm

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 14 下一页

[LeetCode] Word Ladder
摘要:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ... 阅读全文

posted @ 2015-04-08 12:23 Eason Liu 阅读(325) 评论(0) 推荐(0)

[hihoCoder] #1081 : 最短路径·一
摘要:时间限制:10000ms单点时限:1000ms内存限制:256MB描述万圣节的早上,小Hi和小Ho在经历了一个小时的争论后,终于决定了如何度过这样有意义的一天——他们决定去闯鬼屋!在鬼屋门口排上了若干小时的队伍之后,刚刚进入鬼屋的小Hi和小Ho都颇饥饿,于是他们决定利用进门前领到的地图,找到一条通往... 阅读全文

posted @ 2015-04-07 17:17 Eason Liu 阅读(629) 评论(0) 推荐(0)

[Leetcode] Binary Tree Right Side View
摘要:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl... 阅读全文

posted @ 2015-04-05 00:04 Eason Liu 阅读(228) 评论(0) 推荐(0)

[LeetCode] Sort Colors
摘要:Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文

posted @ 2015-04-01 16:26 Eason Liu 阅读(333) 评论(0) 推荐(0)

[LeetCode] House Robber
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo... 阅读全文

posted @ 2015-04-01 15:31 Eason Liu 阅读(214) 评论(0) 推荐(0)

[Leetcode] Longest Palindromic Substring
摘要:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa... 阅读全文

posted @ 2015-03-30 22:04 Eason Liu 阅读(203) 评论(0) 推荐(0)

[LeetCode] Search for a Range
摘要:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文

posted @ 2015-03-27 13:44 Eason Liu 阅读(243) 评论(0) 推荐(0)

[Leetcode] Maximum Gap
摘要:Maximum GapGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/spac... 阅读全文

posted @ 2015-03-21 16:15 Eason Liu 阅读(1041) 评论(0) 推荐(0)

[Leetcode] Reverse Integer
摘要:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321click to show spoilers.Have you thought about this?Here are som... 阅读全文

posted @ 2015-03-21 13:54 Eason Liu 阅读(186) 评论(0) 推荐(0)

[Leetcode] Pow(x, n)
摘要:Implement pow(x,n).注意n等于INT_MIN的时候,直接让n = -n会整形溢出.二分法: 1 class Solution { 2 public: 3 double pow(double x, int n) { 4 if (n == 0) return 1... 阅读全文

posted @ 2015-03-21 13:30 Eason Liu 阅读(150) 评论(0) 推荐(0)

[Leetcode] Combination Sum II
摘要:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Each number ... 阅读全文

posted @ 2015-03-16 22:05 Eason Liu 阅读(165) 评论(0) 推荐(0)

[Leetcode] Search in Rotated Sorted Array
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文

posted @ 2015-03-15 00:43 Eason Liu 阅读(163) 评论(0) 推荐(0)

[LeetCode] Number of 1 Bits
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in... 阅读全文

posted @ 2015-03-10 22:48 Eason Liu 阅读(143) 评论(0) 推荐(0)

[Jobdu] 题目1373:整数中1出现的次数(从1到n整数中1出现的次数)
摘要:题目描述:亲们!!我们的外国友人YZ这几天总是睡不好,初中奥数里有一个题目一直困扰着他,特此他向JOBDU发来求助信,希望亲们能帮帮他。问题是:求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数?为此他特别数了一下1~13中包含1的数字有1、10、11、12、13因此共出现... 阅读全文

posted @ 2015-03-10 22:46 Eason Liu 阅读(320) 评论(0) 推荐(0)

[Jobdu] 题目1377:缓变序列
摘要:题目描述:陈博在写论文时碰到一个难题:如何将给定的整数序列变换成缓变序列:即任意两个相邻的元素相差均为1,第1个元素和最后一个元素相差也为1. 变换是指改变原整数序列中各元素的顺序。例如整数序列1,3,2,2可以变换成缓变序列1,2,3,2. 其中(1,2)、(2,3)、(3,2)相差均为1,第1个... 阅读全文

posted @ 2015-03-10 22:44 Eason Liu 阅读(277) 评论(0) 推荐(0)

[LeetCode] Add Two Numbers
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文

posted @ 2015-03-07 23:13 Eason Liu 阅读(163) 评论(0) 推荐(0)

[LeetCode] Repeated DNA Sequences
摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to ... 阅读全文

posted @ 2015-03-07 21:11 Eason Liu 阅读(1806) 评论(1) 推荐(0)

[LeetCode] Reverse Bits
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ... 阅读全文

posted @ 2015-03-07 21:00 Eason Liu 阅读(1438) 评论(0) 推荐(0)

[Jobdu] 题目1139:最大子矩阵
摘要:题目描述:已知矩阵的大小定义为矩阵中所有元素的和。给定一个矩阵,你的任务是找到最大的非空(大小至少是1 * 1)子矩阵。比如,如下4 * 4的矩阵0 -2 -7 09 2 -6 2-4 1 -4 1-1 8 0 -2的最大子矩阵是9 2-4 1-1 8这个子矩阵的大小是15。输入:输入是一个N * ... 阅读全文

posted @ 2015-01-29 14:04 Eason Liu 阅读(4576) 评论(0) 推荐(0)

[LeetCode] Clone Graph
摘要:Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniq... 阅读全文

posted @ 2015-01-22 16:35 Eason Liu 阅读(168) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 14 下一页