随笔分类 -  Leetcode

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 19 下一页
摘要:Compare two version numbersversion1andversion2.Ifversion1>version2return 1, ifversion1 temp2) return 1;18 if(temp1 < temp2) return -1;19 ... 阅读全文
posted @ 2015-10-08 10:02 amazingzoe 阅读(150) 评论(0) 推荐(0)
摘要:Remove all elements from a linked list of integers that have valueval.ExampleGiven:1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val= 6Return:1 --> 2 --> 3 --... 阅读全文
posted @ 2015-10-08 09:02 amazingzoe 阅读(136) 评论(0) 推荐(0)
摘要:Given apatternand a stringstr, find ifstrfollows the same pattern.Examples:pattern ="abba", str ="dog cat cat dog"should return true.pattern ="abba", ... 阅读全文
posted @ 2015-10-07 21:08 amazingzoe 阅读(134) 评论(0) 推荐(0)
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文
posted @ 2015-10-06 22:48 amazingzoe 阅读(128) 评论(0) 推荐(0)
摘要:A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its index.... 阅读全文
posted @ 2015-10-05 04:12 amazingzoe 阅读(113) 评论(0) 推荐(0)
摘要:Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest formed num... 阅读全文
posted @ 2015-10-03 04:34 amazingzoe 阅读(111) 评论(0) 推荐(0)
摘要:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文
posted @ 2015-10-02 05:57 amazingzoe 阅读(115) 评论(0) 推荐(0)
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文
posted @ 2015-10-01 23:05 amazingzoe 阅读(132) 评论(0) 推荐(0)
摘要:Given an arraynumscontainingn+ 1 integers where each integer is between 1 andn(inclusive), prove that at least one duplicate number must exist. Assume... 阅读全文
posted @ 2015-10-01 08:42 amazingzoe 阅读(126) 评论(0) 推荐(0)
摘要:Find all possible combinations ofknumbers that add up to a numbern, given that only numbers from 1 to 9 can be used and each combination should be a u... 阅读全文
posted @ 2015-10-01 08:30 amazingzoe 阅读(106) 评论(0) 推荐(0)
摘要: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-10-01 08:11 amazingzoe 阅读(129) 评论(0) 推荐(0)
摘要:Given an Iterator class interface with methods:next()andhasNext(), design and implement a PeekingIterator that support thepeek()operation -- it essent... 阅读全文
posted @ 2015-10-01 06:01 amazingzoe 阅读(123) 评论(0) 推荐(0)
摘要:Given an array of strings, group anagrams together.For example, given:["eat", "tea", "tan", "ate", "nat", "bat"],Return: 1 class Solution { 2 public: ... 阅读全文
posted @ 2015-10-01 01:54 amazingzoe 阅读(137) 评论(0) 推荐(0)
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be on... 阅读全文
posted @ 2015-09-29 04:48 amazingzoe 阅读(126) 评论(0) 推荐(0)
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matr... 阅读全文
posted @ 2015-09-29 02:30 amazingzoe 阅读(132) 评论(0) 推荐(0)
摘要:Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For example, givenn... 阅读全文
posted @ 2015-09-24 06:22 amazingzoe 阅读(204) 评论(0) 推荐(0)
摘要:I. Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.Accordi... 阅读全文
posted @ 2015-09-24 06:20 amazingzoe 阅读(164) 评论(0) 推荐(0)
摘要:Note:This is an extension ofHouse Robber.After robbing those houses on that street, the thief has found himself a new place for his thievery so that h... 阅读全文
posted @ 2015-09-15 05:12 amazingzoe 阅读(112) 评论(0) 推荐(0)
摘要:Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文
posted @ 2015-09-12 05:13 amazingzoe 阅读(102) 评论(0) 推荐(0)
摘要:Given an integer array of sizen, find all elements that appear more than⌊ n/3 ⌋times. The algorithm should run in linear time and in O(1) space.Analys... 阅读全文
posted @ 2015-09-12 02:45 amazingzoe 阅读(130) 评论(0) 推荐(0)

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 19 下一页