码迷,mamicode.com
首页 >  
搜索关键字:numbers range    ( 16974个结果
Range-Based for Loops
for ( decl : coll ){ statement}where decl is the declaration of each element of the passed collection coll and for which the statements specified are....
分类:其他好文   时间:2014-06-15 22:11:18    阅读次数:295
Combination Sum
题目 Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C un...
分类:其他好文   时间:2014-06-15 20:00:18    阅读次数:185
Combination Sum II
题目 Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in...
分类:其他好文   时间:2014-06-15 19:24:21    阅读次数:229
poj 2247 Humble Numbers
Humble Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9396   Accepted: 4417 Description A number whose only prime factors are 2,3,5 or 7 is called a...
分类:其他好文   时间:2014-06-15 19:04:15    阅读次数:159
HDu 2138 How many prime numbers 高效Miller素数测试
题目就是给出一组数,让我们测试其中有多少个是素数。 求素数有测试sqrt(n)个数的方法,有筛子方法,不过对于本题这样的题目来说就都不是高效的。 本题使用Miller Rabin素数测试法,效率奇高,对于不是极其大的整数测试都几乎是常数时间。令人神往的算法啊。 网上有个程序,好像是什么吉林的模板程序,不过我一直没看懂他是什么思路写的,是个AC的程序,不过却是错误的,呵呵,因为程序一直把9当做...
分类:其他好文   时间:2014-06-15 18:48:07    阅读次数:194
[LeetCode] Search for a Range [34]
题目 Given a sorted array of integers, find the starting and ending position of a given target value. 解题思路: 查找一个数出现的范围,给一个排好序的数组和一个数,找出这个数在数组中出现的范围。 这个题直接使用一次遍历就可以得到结果,这样的时间复杂度为O(n)。但是对于有序数组我们一般可以使用二分查找可以得到更好的O(logn)的时间复杂度。我们可以使用二分查找找到这个数第一次出现的位置和这个数最后一次出现的位...
分类:其他好文   时间:2014-06-15 16:19:16    阅读次数:237
UItexfile实时验证输入字符
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; {     NSString * toBeString = [textField.text stringByReplacingCharacter...
分类:其他好文   时间:2014-06-15 15:39:11    阅读次数:162
Multiply Strings
题目 Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. 方法 将num1与0-9相乘的结果存...
分类:其他好文   时间:2014-06-14 06:08:30    阅读次数:229
[LeetCode] Decode Ways [33]
题目 A message containing letters from A-Z is being encoded to numbers using the following mapping: 原题链接(点我) 解题思路及代码; 解码方法数量问题。英文26个字母对应1到26,给一串数字,问翻译为字母有多少种方法? 这个题第一思路是想到使用组合排列的方法,穷举所有的可能。很好,写出如下代码... 但是提交后出来的结果是超时。 再想想,使用动态规划的方法来做。 对于串s[0...i]的解码数量应该和s[0.....
分类:其他好文   时间:2014-06-13 20:44:04    阅读次数:292
【Leetcode】Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at...
分类:其他好文   时间:2014-06-13 20:36:56    阅读次数:280
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!