/** * 校验是否为手机号码 * @param string $mobile* @return boolean */function is_mobile($mobile) { if(preg_match('#^13[\d]{9}$|14^[0-9]\d{8}|^15[0-9]\d{8}$...
分类:
移动开发 时间:
2015-07-15 16:55:24
阅读次数:
129
首先来一个 oc 的递归:- (int)sum:(int)num { if (num == 0) { return num; } return num + [self sum:num - 1];}写递归算法只需要记住两点即可:1. 有一个明确的出口2. 不满足条件出口...
分类:
移动开发 时间:
2015-07-15 16:40:52
阅读次数:
133
Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321思路:要注意溢出。用以下做法,会溢出。class Solution {public: int reverse(in...
分类:
其他好文 时间:
2015-07-15 16:40:17
阅读次数:
83
/** * 预防SQL注入攻击 * @param string $value* @return string */function check_input($value){ // 去除斜杠 if (get_magic_quotes_gpc()) { $value = strip...
分类:
数据库 时间:
2015-07-15 16:28:22
阅读次数:
142
/** * 生成随机验证码 * @param string $len 验证码长度 * @return string **/function GetRandStr($len) { $chars = array( "0", "1", "2", "3", "4", "5", "...
分类:
其他好文 时间:
2015-07-15 16:27:32
阅读次数:
112
Merge Intervals
Given a collection of intervals, merge all overlapping intervals.
For example,
Given [1,3],[2,6],[8,10],[15,18],
return [1,6],[8,10],[15,18].
思路:题意很明确,首先对各区间按开始来排序,最后遍历,如...
分类:
其他好文 时间:
2015-07-15 15:09:46
阅读次数:
190
Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.
If the last word does not exist, return...
分类:
其他好文 时间:
2015-07-15 15:08:18
阅读次数:
97
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.
For example,
Given n = 3,
You should return the following matrix:
[
[ 1, 2, 3 ],
[ 8, 9, 4 ]...
分类:
其他好文 时间:
2015-07-15 15:08:07
阅读次数:
253
Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.
For example:
Given 1->2->3->4->5->NULL and k = 2,
return 4->5->1->2->3->NULL.
思路:题目很清晰,思路是先得到...
分类:
其他好文 时间:
2015-07-15 15:06:27
阅读次数:
122
1 int g_tennis; // not use as possible 2 3 int make_world() { 4 int size = 0; 5 6 return size; 7 } 8 9 const int NUMBER = 100;10 11 enu...
分类:
编程语言 时间:
2015-07-15 15:01:15
阅读次数:
146