Compare methodEither you implement a compare-method for your object:- (NSComparisonResult)compare:(Person *)otherObject { return [self.birthDate co...
分类:
其他好文 时间:
2014-09-20 23:09:39
阅读次数:
263
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.难度:60.这是算法中比较经典的问题,判断一个字...
分类:
其他好文 时间:
2014-09-20 14:02:47
阅读次数:
292
[leetcode]Implement pow(x, n)....
分类:
其他好文 时间:
2014-09-20 10:04:17
阅读次数:
110
原题地址:https://oj.leetcode.com/problems/next-permutation/题意:Implement next permutation, which rearranges numbers into the lexicographically next greater...
分类:
编程语言 时间:
2014-09-20 07:44:56
阅读次数:
241
Implement pow(x, n).Analysis:The most basic idea, x multiply itself n time and return. However, this strait forward approach got time excessed. O(n).N...
分类:
其他好文 时间:
2014-09-20 01:04:26
阅读次数:
207
Implement int sqrt(int x).难度:76,用二分查找。要求是知道结果的范围,取定左界和右界,然后每次砍掉不满足条件的一半,知道左界和右界相遇。算法的时间复杂度是O(logx),空间复杂度是O(1)。 1 public class Solution { 2 public ...
分类:
其他好文 时间:
2014-09-19 13:45:15
阅读次数:
122
1.Implement a functionthat prints the numbers from 1 to 100.But for multiples of three(3) print “Zif”insteadof the number and for the multiples of five(5) print “Nab”. For numbers whichare multiples...
分类:
编程语言 时间:
2014-09-19 12:06:25
阅读次数:
198
1.strstr() 函数搜索一个字符串在另一个字符串中的第一次出现。找到所搜索的字符串,则该函数返回第一次匹配的字符串的地址;如果未找到所搜索的字符串,则返回NULL。2.strcat() 函数用来连接字符串,其原型为: char *strcat(char *dest, const char .....
分类:
编程语言 时间:
2014-09-18 13:02:13
阅读次数:
224
摘要:本文试着比较c++字符串与C风格字符串,主要讨论的是c++中的字符串的简单操作。1、C风格字符串的主要操作与缺陷;主要操作有: strlen (求长度)、strcpy(复制字符串) 、strcmp(比较字符串大小)、strcat(字符串连接)、strstr(寻找子字符串)C标准库实现:char...
分类:
编程语言 时间:
2014-09-18 01:59:13
阅读次数:
338
字符串替换
写一个字符串替换函数,如母串"123123123123",把母串中的子串"123",替换为"12345",或者"12"。
思路:
利用库函数strstr(),定位子串。使用strcpy()进行替换。不断重复着定位和替换动作,直到定位到NULL为止。...
分类:
其他好文 时间:
2014-09-17 01:12:21
阅读次数:
308