摘要:
题目:Write a function to find the longest common prefix string among an array of strings.思路:1. 设定初始Prefix为"" 2. 对第二个字符串-最后一个字符串里的第n个字母进行循环。以第一个字符串里的第n个字 阅读全文
摘要:
做这道题之前首先要知道罗马数字的规律。 There are a few rules for writing numbers with Roman numerals. 1. Repeating a numeral up to three times represents addition of the 阅读全文
摘要:
第二道简单题,这道题主要是取余的思想,但我们平常遇到的位数较少的数字只要对个十百分别取余再拼起来就行了,这道题的话因为最大位数可以是[-231,231-1],所以就要用到循环取余。 1. Given an integer x 以下循环,直到X为0: 2. X对10取余,获得其个位数 3. X/10 阅读全文
摘要:
今天做了第一道简单题。Two Sum。以下是题目。 我用一种比较笨的办法写了一下,nested loop只打败了16.12%的人。 Time complixity:O(n2) For each element, we try to find its complement by looping thr 阅读全文
摘要:
这里主要是记录一些我在学习过程中认为需要特别注意的地方。 vector的initialization。 Conventional STL: 常用的push_back: C++ 11中可以使用的赋值语句。 还有一些引入其他library的方法。 Using boost list_of: Using b 阅读全文