码迷,mamicode.com
首页 >  
搜索关键字:return    ( 60766个结果
数据结构基础 算法复杂度分析(二) 典例篇
示例代码(1) decimal Factorial(int n) { if (n == 0) return 1; else return n * Factorial(n - 1); } 【分析】 阶乘(factorial),给定规模 n,算法基本步骤执行的数量为 n,所以算法复杂度为 O(n)。 示例代码(2) int FindMaxElement(int[] array) { int max = array[0]...
分类:编程语言   时间:2015-08-02 21:43:05    阅读次数:174
LeetCode242——Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s = "rat", t = "car", return false. Note: You may a...
分类:其他好文   时间:2015-08-02 21:34:46    阅读次数:104
Count and Say
class Solution {public: string countAndSay(int n) { string res; if(n<=0) return res; res += '1'; for(int i=0;i<n-1;...
分类:其他好文   时间:2015-08-02 21:32:48    阅读次数:111
Search in Rotated Sorted Array
class Solution {public: int search(vector& nums, int target) { return rotate_search(nums,0,nums.size()-1,target); } int rotate_search(...
分类:其他好文   时间:2015-08-02 21:24:04    阅读次数:117
[leedcode 173] Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next...
分类:其他好文   时间:2015-08-02 19:47:38    阅读次数:107
C语言编程入门——指针(下)
函数的重载: # include void swap(void) { printf("呵呵!\n"); return; } void swap(int i, int j) { printf("哈哈!\n"); return; } int main(void) { swap(); swap(1, 2); //函数名相同,形参个数不同,也不是同一个函数。 int i ...
分类:编程语言   时间:2015-08-02 18:22:32    阅读次数:151
下载图片-使用正则表达式
图片处理如何处理图片 拿到网页 使用正则表达式匹配 使用urlretrieve下载图片 import re import urllib2 import urllibdef getContext(url): ''' 获取html ''' html = urllib2.urlopen(url) return html.read()def getPicture(htm...
分类:其他好文   时间:2015-08-02 18:21:29    阅读次数:100
Leetcode-Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where in...
分类:其他好文   时间:2015-08-02 18:20:21    阅读次数:112
C语言编程入门——指针与函数、数组
总结一下指针与函数和数组的关系及相关练习。 传统数组的缺点: # include int main(void) { //数组的定义 int len = 5; int a[len]; //错误,数组的长度必须直接指定,且不能更改。 int b[5]; //正确。 return 0; } 确定一个数组需要几个参数: # include //本函数功能是输出任意一...
分类:编程语言   时间:2015-08-02 18:20:03    阅读次数:164
字符串翻转-不能使用系统函数
思想 定义头尾两个指针 交换头尾指针的数据 //字符串翻转 char *strrev(char *str){ //判断字符是否为null或是空字符串 if(str == NULL || str == '\0') { return str; } //定义char数组指针 char *start = str; char...
分类:其他好文   时间:2015-08-02 18:19:11    阅读次数:123
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!