码迷,mamicode.com
首页 >  
搜索关键字:recursion    ( 476个结果
LeetCode(17):电话号码的字母组合
Medium! 题目描述: 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。 给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 示例: 输入:"23" 输出:["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "c ...
分类:其他好文   时间:2018-06-03 12:20:22    阅读次数:192
排序算法杂谈(二) —— 冒泡排序的递归实现
众所周知,循环和递归,在很多情况下是可以互相转换的。 那么,冒泡排序(Bubble Sort),作为典型的双重循环结构,也可以将其转化成递归形式。 但是,将递归转化为循环,对于程序的运行是有益的,因为它避免了不可预知的“方法压栈”的现象出现。 而将循环化为递归,多数情况下,不推荐这么做,即使递归的代 ...
分类:编程语言   时间:2018-05-23 20:29:24    阅读次数:246
LeetCode - Binary Tree Longest Consecutive Sequence
Recursion: 时间O(n) 空间O(h) 因为要找最长的连续路径,我们在遍历树的时候需要两个信息,一是目前连起来的路径有多长,二是目前路径的上一个节点的值。我们通过递归把这些信息代入,然后通过返回值返回一个最大的就行了。 ...
分类:其他好文   时间:2018-05-23 11:57:56    阅读次数:163
132. Palindrome Partitioning II
dp or memo recursion 1. dp formulation 2. ispalindrome based on the nature structure ...
分类:其他好文   时间:2018-05-19 11:08:20    阅读次数:204
【练习】分解命名空间
/** * 递归方式分解命名空间 * @param namespace * @return 分解后的list集合 */ private static List recursion(String namespace) { int index = namespace.indexOf("."); List... ...
分类:其他好文   时间:2018-05-09 12:09:07    阅读次数:142
递归函数
递归函数 递归函数的定义: 在一个函数里调用他本身,这种使用函数的方式就叫这做递归。 递归的最大深度: 最后得出结论,递归的最大深度是997,为什么是997呢,是因为python为了我们程序的内存优化所设定的一个默认值,我们当然还可以通过一些手段去修改它: 虽然说我们可以根据这个方式修改递归最大限制 ...
分类:其他好文   时间:2018-05-07 21:44:18    阅读次数:193
关于python最大递归深度 - 998
今天LeetCode的时候暴力求解233 问题: 给定一个整数 n,计算所有小于等于 n 的非负数中数字1出现的个数。 例如: 给定 n = 13, 返回 6,因为数字1出现在下数中出现:1,10,11,12,13。 代码: 错误: maximum recursion depth exceeded ...
分类:编程语言   时间:2018-04-30 00:00:18    阅读次数:327
Second last week for the second last semester!
This week, I focused more on the final project, such as H335(Computer structure, still confused with the stack frame and recursion) and B365(plan to t ...
分类:其他好文   时间:2018-04-27 13:48:49    阅读次数:138
python—模块-sys
import sys ...
分类:编程语言   时间:2018-04-22 20:00:09    阅读次数:198
Lintcode371 Print Numbers by Recursion solution 题解
【题目描述】 Print numbers from 1 to the largest number with N digits by recursion. Notice It's pretty easy to do recursion like: recursion(i) { if i > larg ...
分类:其他好文   时间:2018-04-06 12:22:46    阅读次数:163
476条   上一页 1 ... 13 14 15 16 17 ... 48 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!