摘要:
本题最简单的思路是从后往前判断子串是否是回文串,然后把后面的弄到前面即可,不过这样仅仅能擦边通过测试 Brute Force: O(N^2), space O(1) DP: O(N^2), space O(N^2) KMP介绍:http://kb.cnblogs.com/page/176818/ 实 阅读全文
摘要:
ind all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a... 阅读全文
摘要:
Analysis: if the last one is not robbed, then you are free to choose whether to rob the first one. you can break the circle by assuming the first hous 阅读全文
摘要:
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the ... 阅读全文
摘要:
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For examp... 阅读全文
摘要:
Use HashSet: 阅读全文
摘要:
Haven't think about the O(nlogn) solution. O(n) solution is to maintain a window My solution: shrink as much as possible while maintaining the window 阅读全文
摘要:
方法1:brute force: search function compares each word with the pattern, time complexity: O(nk), n is number of words in dictionary, k is averge length 方 阅读全文