- 博客(10)
- 收藏
- 关注
原创 (Java)LeetCode-29. Divide Two Integers
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.刚看这一题时确实没什么思路,还想着一直减减减,后来看到tags里有二分查找,就有思路了。amazing比如说 25/3 这一题,用一个Map存上(3-1)(6-
2016-06-14 14:51:54 332
原创 (Java)-LeetCode-336. Palindrome Pairs
Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.Example 1:Give
2016-06-13 21:06:41 1007
原创 (Java)LeetCode-214. Shortest Palindrome
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation.For exam
2016-06-12 15:21:55 346
原创 (Java)LeetCode-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.这道题,首先我使用的是暴力查找法,用两个指针分别指向needle和haystack,然后移动比较即可,我自己写了一个版本,感
2016-06-09 13:37:16 392
原创 (Java)LeetCode-27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.
2016-06-08 15:16:59 1450 1
原创 (Java)LeetCode-26. Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with
2016-06-08 15:08:30 387
原创 (Java)LeetCode-25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is
2016-06-02 22:06:36 2032
原创 (Java)LeetCode-24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y
2016-06-02 16:53:15 981
原创 (Java)LeetCode-23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.首先说明这道题我的代码运行时间可以排进前70%呀~开心~还是hard模式这道题首先想到的是用k个指针分别指向每个List的头部,再其次遍历,不过这样每次都要求k个数里面的最小值,不
2016-06-02 00:23:11 226
原创 (Java)LeetCode-22. Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()
2016-06-01 16:19:45 711
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人