随笔分类 -  LeetCode 题目

219. Contains Duplicate II
摘要:Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d... 阅读全文

posted @ 2015-06-03 04:50 shini 阅读(160) 评论(0) 推荐(0)

33. 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-05-29 08:45 shini 阅读(93) 评论(0) 推荐(0)

28. Implement strStr()
摘要:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The si... 阅读全文

posted @ 2015-05-28 08:40 shini 阅读(93) 评论(0) 推荐(0)

27.Remove Element
摘要:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文

posted @ 2015-05-28 08:27 shini 阅读(92) 评论(0) 推荐(0)

26. Remove Duplicates from Sorted Array
摘要:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a... 阅读全文

posted @ 2015-05-28 08:23 shini 阅读(83) 评论(0) 推荐(0)

22. Generate Parentheses
摘要:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))... 阅读全文

posted @ 2015-05-28 08:12 shini 阅读(87) 评论(0) 推荐(0)

24. Swap Nodes in Pairs
摘要:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文

posted @ 2015-05-14 08:18 shini 阅读(101) 评论(0) 推荐(0)

21. Merge Two Sorted Lists
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.经典实现题。/**... 阅读全文

posted @ 2015-05-13 08:24 shini 阅读(82) 评论(0) 推荐(0)

20. Valid Parentheses
摘要:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文

posted @ 2015-05-13 08:20 shini 阅读(125) 评论(0) 推荐(0)

19. Remove Nth Node From End of List
摘要:Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re... 阅读全文

posted @ 2015-05-13 08:09 shini 阅读(111) 评论(0) 推荐(0)

17. Letter Combinations of a Phone Number
摘要:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon... 阅读全文

posted @ 2015-05-13 05:06 shini 阅读(108) 评论(0) 推荐(0)

209. Minimum Size Subarray Sum
摘要:Given an array ofnpositive integers and a positive integers, find the minimal length of a subarray of which the sum ≥s. If there isn't one, return 0 i... 阅读全文

posted @ 2015-05-12 05:38 shini 阅读(146) 评论(0) 推荐(0)

11. Container With Most Water
摘要:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文

posted @ 2015-04-30 06:58 shini 阅读(118) 评论(0) 推荐(0)

8. String to Integer (atoi)
摘要:Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文

posted @ 2015-04-30 06:45 shini 阅读(105) 评论(0) 推荐(0)

9. Palindrome Number
摘要:Determine whether an integer is a palindrome. Do this without extra space.类似于reverse integer。public class Solution { public boolean isPalindrome(... 阅读全文

posted @ 2015-04-30 06:21 shini 阅读(107) 评论(0) 推荐(0)

7. Reverse Integer
摘要:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321注意溢出,溢出返回0public class Solution { public int reverse(int x... 阅读全文

posted @ 2015-04-30 06:18 shini 阅读(130) 评论(0) 推荐(0)

5. 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-04-30 02:39 shini 阅读(83) 评论(0) 推荐(0)

128. Longest Consecutive Sequence
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文

posted @ 2015-04-30 00:36 shini 阅读(106) 评论(0) 推荐(0)

2. 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-04-29 11:26 shini 阅读(99) 评论(0) 推荐(0)

205. Isomorphic Strings
摘要:Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a ... 阅读全文

posted @ 2015-04-29 11:14 shini 阅读(113) 评论(0) 推荐(0)

导航