1.3 Given two strings, write a method to decide if one is a permutation of the other.这道题给定我们两个字符串,让我们判断一个是否为另一个的全排列字符串。在LeetCode中,关于排列的题有如下几道,Permutat...
分类:
其他好文 时间:
2015-07-16 09:36:18
阅读次数:
138
1.2 Implement a function void reverse(char *str) in C or C++ which reverses a null-terminated string.这道题让我们用C++或C语言来翻转一个字符串,不算一道难题,在之前那道Reverse Words ...
分类:
其他好文 时间:
2015-07-16 00:28:29
阅读次数:
146
1.1 Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structure?这道题让我们判断一个字符串中是否有重复的字符...
分类:
其他好文 时间:
2015-07-15 14:56:26
阅读次数:
100
【称号】原文:1.8 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check ...
分类:
其他好文 时间:
2015-07-03 20:29:20
阅读次数:
138
Spent time to write down C# program to implement an algorithm. Feel great! Start to practice, a question a time.Question is from careercup:http://www....
分类:
其他好文 时间:
2015-04-01 08:17:38
阅读次数:
225
1. leetcodehttp://leetcode.com/2. careeruphttp://www.careercup.com/http://hawstein.com/posts/ctci-solutions-contents.html3. glassdoorhttp://www.glassd...
分类:
编程语言 时间:
2015-02-17 07:03:07
阅读次数:
878
- G: a vector of strings, find a pair with max of strlen(a) * strlen(b) 1. O(n*k): get std::bitset() of each string 2. O(nlgn): sort strings by leng.....
分类:
其他好文 时间:
2015-01-18 11:48:41
阅读次数:
168
这题要收费了。只能网上看题目,我等屌丝也没法OJ测试了。网上看了后发现其实并非独创,其他的方也有类似的题。例如在这里,CareerCup上先用了递归的想法, TreeNode *ans; TreeNode *helper156(TreeNode *root) { if...
分类:
其他好文 时间:
2014-12-19 12:05:48
阅读次数:
167
17.12 设计一个算法,找出数组中两数之和为指定值的所有整数对。解答时间复杂度O(n)的解法我们可以用一个哈希表或数组或bitmap(后两者要求数组中的整数非负)来保存sum-x的值, 这样我们就只需要遍历数组两次即可找到和为指定值的整数对。这种方法需要O(n) 的辅助空间。如果直接用数组或是bi...
分类:
其他好文 时间:
2014-12-13 16:25:16
阅读次数:
153
17.11 给定rand5(),实现一个方法rand7().也即,给定一个产生0到4(含)随机数的方法,编写一个产生0到6(含)随机数的方法。解法:这个函数要正确实现,则返回0到6之间的值,每个值的概率必须为1/7.1 第一个尝试(调用次数固定)第一个尝试时,我们可能会想产生出0到9之间的值,然后再...
分类:
其他好文 时间:
2014-12-13 13:25:34
阅读次数:
119