上一页 1 2 3 4 5 6 7 ··· 17 下一页
摘要: '.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not partial).The function prototype should be:bool isMatch(const char *s, const char *p)Some examples:isMatch("aa","a") → falseisM 阅读全文
posted @ 2013-10-08 14:19 懒猫欣 阅读(204) 评论(0) 推荐(0)
摘要: Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab",Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut.首 阅读全文
posted @ 2013-10-08 00:32 懒猫欣 阅读(181) 评论(0) 推荐(0)
摘要: Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s. For example, given s = "aab",Return [ ["aa","b"], ["a","a","b"] ]输出总共2^n种,硬做就可以了class Solution {publi 阅读全文
posted @ 2013-10-07 23:05 懒猫欣 阅读(141) 评论(0) 推荐(0)
摘要: The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312""321"Given n and k, return the kth permutation se 阅读全文
posted @ 2013-10-07 21:32 懒猫欣 阅读(141) 评论(0) 推荐(0)
摘要: Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.目标是找出所有字母集合相同的词,例如aabc和abca通过hash就可以了class Solution {public: vector anagrams(vector &strs) { // Note: The Solution object is instantiated only once and is reused by each test ca... 阅读全文
posted @ 2013-10-07 20:56 懒猫欣 阅读(182) 评论(0) 推荐(0)
摘要: Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each 阅读全文
posted @ 2013-10-07 20:38 懒猫欣 阅读(199) 评论(0) 推荐(0)
摘要: Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).总共可以买卖 阅读全文
posted @ 2013-10-07 15:10 懒猫欣 阅读(151) 评论(0) 推荐(0)
摘要: Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions 阅读全文
posted @ 2013-10-07 13:18 懒猫欣 阅读(148) 评论(0) 推荐(0)
摘要: Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.题目的意思是所有天加起来只能最多买一次买一次class Solution {public: int max... 阅读全文
posted @ 2013-10-07 13:09 懒猫欣 阅读(128) 评论(0) 推荐(0)
摘要: Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.据说没有递推公式class Solution {public: int check(int* X,int k){ for(int i=0;i=0) { X[j]++; if(X[j]==n) { j--; ... 阅读全文
posted @ 2013-10-07 00:02 懒猫欣 阅读(146) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 17 下一页