码迷,mamicode.com
首页 >  
搜索关键字:python题目    ( 131个结果
Leetcode 100 Same Tree python
题目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identic ...
分类:编程语言   时间:2016-04-16 15:16:17    阅读次数:195
Leetcode 226 Invert Binary Tree python
题目: Invert a binary tree. 翻转二叉树。 递归,每次对节点的左右节点调用invertTree函数,直到叶节点。 python中也没有swap函数,当然你可以写一个,不过python中可以通过:a, b = b, a交换两个变量的值 ...
分类:编程语言   时间:2016-04-16 00:43:42    阅读次数:174
[LeetCode]题解(python):015-3Sum
题目来源:https://leetcode.com/problems/3sum/题意分析: 这道题目是输入一个数组nums。找出所有的3个数使得这3个数之和为0.要求1.输出的3个数按小到大排序,2.3个数的组合不重复。比如输入[-1,0,1,2,-1,-4],返回的应该是[[-1,0,1],[-....
分类:编程语言   时间:2015-09-18 23:25:40    阅读次数:229
python题目练习
1、随机生成一个大文件(5G以上),查找里面内容最长的N(N>5)行,并打印出来[root@saltstack-ui~]#catgen_large_file.py importos withopen("a.txt","w")asf: f.write(os.urandom(1024*1024*1024*5))#产生一个5G大小的文件,里面都是随机内容,耗时长,有待改进 [root@saltst..
分类:编程语言   时间:2015-07-30 23:42:37    阅读次数:210
【leetcode】Candy(python)
题目要求的比它的邻居比自己奖励,因此,我们有最少一个多的。所有我们可以找到所有的坑,凹坑例如,存在以下三种情况。找到全部的凹点后,我们就能够从凹点处開始向左右两个方向依次查找递增序列。当中每一个高的都要比相邻的矮的多一个。比方1,2,5,4.我们找到凹点为1 和4,那么从1開始向左没有其它点,我们向...
分类:编程语言   时间:2015-07-08 16:23:09    阅读次数:123
leetcode Palindrome Number Python
题目:Determine whether an integer is a palindrome. Do this without extra space. 刚开始看到题目的时候想着用栈来处理,每进来一个数与栈顶元素比较相同则栈顶元素处栈,不同则元素入栈,最后栈为空或剩一个数为真,我是以“12343....
分类:编程语言   时间:2014-10-15 19:45:31    阅读次数:249
[leetcode] Integer to Roman @ Python
题目: https://oj.leetcode.com/problems/integer-to-roman/Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from ...
分类:编程语言   时间:2014-09-17 06:46:11    阅读次数:285
[leetcode] Roman to Integer @ Python
题目:https://oj.leetcode.com/problems/roman-to-integer/Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1...
分类:编程语言   时间:2014-09-17 06:45:51    阅读次数:269
[leetcode] Add Binary @Python
题目:https://oj.leetcode.com/problems/add-binary/Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "10...
分类:编程语言   时间:2014-09-16 10:31:00    阅读次数:174
【leetcode】Candy(python)
题目要求比其高的邻居要比本身的奖励多,那么最少也要多一个,所有我们可以找到所有的凹点,凹点如下三种情形。 找到所有的凹点后,我们就可以从凹点处开始向左右两个方向依次查找递增序列,其中每个高的都要比相邻的矮的多一个,比如1,2,5,4.我们找到凹点为1 和4,那么从1开始向左没有其他点,我们向右,依次得到2 比1高,2的糖果应该是1的基础上加1,为2, 5比2高,5的糖果是在2的基础上加1...
分类:编程语言   时间:2014-07-18 23:14:20    阅读次数:373
131条   上一页 1 ... 11 12 13 14 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!