![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 89
零件儿
这个作者很懒,什么都没留下…
展开
-
LeetCode-66. Plus One
题目:Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digits ar...原创 2018-03-26 18:06:04 · 105 阅读 · 0 评论 -
LeetCode-67. Add Binary
题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".不会写的人只能偷懒,我庸俗~~~solution:class Solution: def addBinary(self, a, b): """ ...原创 2018-03-26 18:36:01 · 123 阅读 · 0 评论 -
LeetCode-69. Sqrt(x)
题目:Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negative integer.Example 1:Input: 4Output: 2Example 2:Input: 8Output: 2Explanation: The square root...原创 2018-03-26 18:53:35 · 114 阅读 · 0 评论 -
LeetCode-70 climbing stairs(方法大总结)
https://leetcode.com/problems/climbing-stairs/description/题目You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways ...原创 2018-03-26 23:16:11 · 437 阅读 · 0 评论 -
LeetCode-83. Remove Duplicates from Sorted List
题目:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.solut...原创 2018-03-28 11:48:02 · 118 阅读 · 0 评论 -
全国高校计算大赛 模拟赛 第三阶段 python版 题解
标签推荐#这回只有IDE下的,好气import pandas as pdclass Task: def func(self): tf_train_list, tf_test_list = loadSimpDat() initSet = createInitSet(tf_train_list) myFPtree, myHeader...原创 2018-10-11 22:41:20 · 1178 阅读 · 2 评论 -
全国高校绿色计算大赛 模拟赛 第一阶段 python版题解
(一)求和挑战任务这次“绿盟杯”大赛,小明作为参赛选手在练习的时候遇到一个问题,他要对一个范围的两个数进行数位的累加,例如有两个数 15,19则 他们的数位和应该为:1+5+1+6+1+7+1+8+1+9,结果为40。你来帮他解决这个问题吧。编程要求补充完善右侧代码区中的getSum(self,num1,num2)函数,实现对两个数num1和num2的数位和相加,最后返回计算的...原创 2018-10-08 22:23:06 · 1259 阅读 · 0 评论 -
全国高校计算大赛 模拟赛 第二阶段 python版 题解
(一)气温预测挑战任务根据每日气温数组,请重新生成一个数组,新数组对应位置的是你需要再等待多久温度才会升高的天数。如果之后都不会升高,请用0来代替。例如:给定一个数组 temps = {34,35,33,25,44,19,18,17} 新生成的数组应该为[1, 3, 2, 1, 0, 0, 0, 0]。temps数组第一天温度是34℃,第二天是35℃,所以对应新生成数组位置的数据应...原创 2018-10-09 10:38:56 · 925 阅读 · 2 评论 -
“绿盟杯”模拟赛第一阶段(Python版题解)
(一)简单排序挑战任务本次挑战,你需要根据输入的排序类型,实现对输入数组的排序。其中,排序类型包括asc(升序)或desc(降序)。编程要求补充完善右侧代码区中的sortArray(self,arr,sort)函数,实现对给定数组的排序。其中,函数各参数含义如下:arr:输入数组 sort:排序类型测试说明样例1输入:23,12,2,32,11,125asc输出...原创 2018-10-19 16:36:17 · 1968 阅读 · 2 评论 -
绿盟杯决赛第一阶段 python 题解
(一)简单排序挑战任务本关挑战任务是对一个数组进行排序,排序需要遵守一些规则,比如给出一组数据5,1,4,2,3,我们从第二个数字开始,这个数字是1,我们的任务是看看1有没有在正确的位置,我们的做法是和这个数字左边的数字来比,因此我们比较1和5,1比5小,所以交换1和5,原来的排列就变成了1,5,4,2,3。接下来我们看第三个数字有没有在正确的位置。这个数字是4,它的左边数字是5,4比...原创 2018-10-25 15:37:05 · 1788 阅读 · 0 评论 -
“绿盟杯”模拟赛第二阶段(Python题解) 集装箱货运问题
集装箱货运问题任务概述集装箱货运是国际货物运输的主要方式之一,在进行码头运货时,会先将不同类型的物品都装入集装箱,然后再统一运送。集装箱通常有统一的规格。本关挑战是需要你设计算法,要求将码头已有的多种类型的货物使用给定规格的集装箱进行组合装箱,并使得集装箱的载重和空间利用率尽可能的高。数据说明假设货运码头仅有一种规格的集装箱,其体积是56立方米,最多能放入重量为128千克的物品...翻译 2018-10-23 22:26:47 · 2992 阅读 · 2 评论 -
“绿盟杯”决赛第二阶段(Python题解)
(一)生日蜡烛挑战任务参加“绿盟杯”决赛的小明同学从18岁之后的某一年开始每年都会在他家的别墅举办一次生日派对,在每一次办生日派对的时候都会有一个吹蜡烛的环节,小明都会吹灭与年龄相同数量的生日蜡烛。你需要编写一个程序,根据总共吹灭的蜡烛数量,来判断小明同学现在多少岁了。编程要求补全右侧代码区中的birthdayCandle(num)函数,实现通过吹灭蜡烛的根数来判断小明的最小年...原创 2018-10-26 11:09:35 · 1510 阅读 · 1 评论 -
LeetCode-53. Maximum Subarray
题目:Maximum Subarray Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarra...转载 2018-03-26 16:17:35 · 99 阅读 · 0 评论 -
LeetCode-38 count and say
题目:The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11.11 is read off as...原创 2018-03-25 21:51:16 · 160 阅读 · 0 评论 -
LeetCode-1 两数之和
给定一个整数数列,找出其中和为特定值的那两个数。你可以假设每个输入都只会有一种答案,同样的元素不能被重用。示例:给定 nums = [2, 7, 11, 15], target = 9因为 nums[0] + nums[1] = 2 + 7 = 9所以返回 [0, 1]step 1:class Solution(object): def twoSum(self, nums, targe...原创 2018-03-19 21:14:57 · 625 阅读 · 0 评论 -
leetcode-7颠倒整数
给定一个范围为 32 位 int 的整数,将其颠倒。例 1:输入: 123输出: 321 例 2:输入: -123输出: -321 例 3:输入: 120输出: 21 注意:假设我们的环境只能处理 32 位 int 范围内的整数。根据这个假设,如果颠倒后的结果超过这个范围,则返回 0。class Solution: def reverse(self, x): ""...原创 2018-03-20 10:50:03 · 291 阅读 · 0 评论 -
LeetCode-21. Merge Two Sorted Lists
题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1-&g...原创 2018-03-24 11:40:16 · 120 阅读 · 0 评论 -
LeetCode-26. Remove Duplicates from Sorted Array
题目:Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifying t...原创 2018-03-24 12:22:55 · 78 阅读 · 0 评论 -
LeetCode-27. Remove Element
题目:Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-pla...原创 2018-03-24 12:44:08 · 173 阅读 · 0 评论 -
LeetCode-9回文数
题目:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to string, note...原创 2018-03-20 22:05:22 · 115 阅读 · 0 评论 -
LeetCode-28. Implement strStr()
题目:Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example 2:Inp...原创 2018-03-25 10:18:59 · 152 阅读 · 0 评论 -
LeetCode-35. Search Insert Position
题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.E...原创 2018-03-25 11:19:13 · 136 阅读 · 0 评论 -
LeetCode-13罗马数字转整数
"""罗马数字只有7个字母组成,每个字母代码的字如下:ROMAN = {'M':1000,'D':500,'C':100,'L':50,'X':10,'V':5,'I':1}题目hint1中给出,注意格式即可没有明确给出罗马数字与阿拉伯数字的转换关系,已有总结如下:四个规则(http://blog.csdn.net/net_wolf_007/article/details/51770112)相...原创 2018-03-21 09:58:48 · 584 阅读 · 0 评论 -
LeetCode-14 longest common prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.解题思路:恩新手复习下zip,set好了……class Solution: def longestCommonPrefix(self, strs): """ :type strs: ...原创 2018-03-21 10:57:17 · 130 阅读 · 0 评论 -
LeetCode-20 valid parenthesis
题目:括号匹配问题Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all v...原创 2018-03-21 11:48:23 · 185 阅读 · 0 评论