8. String to Integer (atoi) Total Accepted: 91403 Total Submissions: 683692 Difficulty: Easy Implement atoi to convert a string to an integer. Hint: C
分类:
其他好文 时间:
2016-03-10 21:57:23
阅读次数:
251
用两个队列去实现栈,这里我使用了队列数组q[2],在所有的过程中保证一个队列是空的 push时插入到空的队列中,然后将队列中的元素移到另一个队列中 pop时从不空的队列中pop() peek时从不空的队列中取出front() 1 class Stack { 2 public: 3 queue<int
分类:
其他好文 时间:
2016-03-09 22:22:14
阅读次数:
180
今天做了一道题,要用判断一个字符串是否是另一个字符串的子串,于是查了一下strstr的实现。 代码如下: 1 char *strstr(const char*s1,const char*s2) 2 { 3 const char*p=s1; 4 const size_t len=strlen(s2);
分类:
编程语言 时间:
2016-03-09 17:24:32
阅读次数:
283
Class-based actorsA class-based actor is a subtype of event_based_actor and must implement the pure virtual member function make_behavior returning th
分类:
编程语言 时间:
2016-03-09 10:53:42
阅读次数:
171
原文网址:http://www.cnblogs.com/nuistlr/archive/2012/09/07/2675649.html 首先要继承OnItemLongClickListener public class Set_Music extends ListActivity implement
分类:
移动开发 时间:
2016-03-08 00:22:01
阅读次数:
147
Implement int sqrt(int x). Compute and return the square root of x. sqrt(3) = 1 sqrt(4) = 2 sqrt(5) = 2 sqrt(10) = 3 mid*mid 以及 (mid + 1) * (mid + 1)都
分类:
其他好文 时间:
2016-03-07 08:55:58
阅读次数:
146
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. AC代码: class Solution(obj
分类:
其他好文 时间:
2016-03-07 01:19:29
阅读次数:
142
Sqrt(x):Implement int sqrt(int x).Compute and return the square root of x. 题意:实现开方函数。 思路:采用二分查找的方式进行,判断。 代码: ublic class Solution { public int mySqrt(...
分类:
其他好文 时间:
2016-03-06 20:44:48
阅读次数:
153
翻译实现pow(x, n).原文Implement pow(x, n).分析首先给大家推荐维基百科:zh.wikipedia.org/wiki/二元搜尋樹 en.wikipedia.org/wiki/Binary_search_tree 其次,大家也可以看看类似的一道题:LeetCode 69 Sqrt(x)(Math、Binary Search)(*) 然而这题我还是没有解出来,看看别人的解法……...
分类:
其他好文 时间:
2016-03-05 23:52:37
阅读次数:
377
原题链接在这里:https://leetcode.com/problems/zigzag-iterator/ 题目: Given two 1d vectors, implement an iterator to return their elements alternately. For examp
分类:
其他好文 时间:
2016-03-05 01:34:10
阅读次数:
227