Well, a typical backtracking problem. Make sure you are clear with the following three problems:What is a partial solution and when is it finished? --...
分类:
其他好文 时间:
2015-06-18 00:43:15
阅读次数:
202
题意:回文数字。原题来自:https://leetcode.com/problems/reverse-integer/分析:根据题目要求,Reverse digits of an integer.我理解为int的范围了,结果,这题很坑。最先wa的时候,我还以为int范围小了,就用long long,...
分类:
其他好文 时间:
2015-06-17 21:27:48
阅读次数:
146
题意:最长回文子串。原题来自:https://leetcode.com/problems/longest-palindromic-substring/分析:有2种解法,字符串解析(KMP算法,我忘了),还有一种,直接用动态规划搞定。不晓得动态规划方法的朋友,自己百度学下这方法,该方法用处很多。至于K...
分类:
其他好文 时间:
2015-06-17 21:16:07
阅读次数:
121
题意:给2个数组,求他们的中位数(中间那个数)。原题来自:https://leetcode.com/problems/median-of-two-sorted-arrays/分析:我自己的思路,2数组合并成一个数组,然后sort,最后求中间那数(如果数组长度为偶数,就中间2数的平均数)。 1 cla...
分类:
其他好文 时间:
2015-06-17 19:41:23
阅读次数:
125
Well, a typical backtracking problem. Make sure you are clear with the following three problems:What is a partial solution and when is it finished? --...
分类:
其他好文 时间:
2015-06-17 00:34:16
阅读次数:
142
https://leetcode.com/problems/rectangle-area/今天做这道题发现了溢出的问题1 int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {2 int overla...
分类:
其他好文 时间:
2015-06-16 14:37:42
阅读次数:
110
https://leetcode.com/problems/single-number/
这是来自于leetcode上的一道题目。这里主要强调的是解决题目时候必须数学先行。题目虽然很简单,不假思考就可以给出几个很直观的答案,但是由于时间复杂度是O(nlogn)空间复杂度是O(n)
Given an array of integers, every element appears t...
分类:
其他好文 时间:
2015-06-15 23:59:46
阅读次数:
291
Problem Description
It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string....
分类:
其他好文 时间:
2015-06-15 18:52:24
阅读次数:
106
Add Binary: https://leetcode.com/problems/add-binary/Given two binary strings, return their sum (also a binary string).For example,
a = “11”
b = “1”
Return “100”.本题关键点在于:
1. 从后往前计算,但是结果字符串应该是从最前插入每...
分类:
其他好文 时间:
2015-06-15 16:25:15
阅读次数:
113
String to Integer (atoi) : https://leetcode.com/problems/string-to-integer-atoi/问题描述Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a cha...
分类:
其他好文 时间:
2015-06-15 09:30:00
阅读次数:
240