- 博客(21)
- 收藏
- 关注
原创 疑惑
class Solution: def FindNumber(self,array): res = [] array.sort() q = len(array) -1 i = 0 while i < q: if array[i] == array[i+1]: i =...
2018-03-26 22:20:37 179
原创 lintcode 46.主元素
class Solution: """ @param: nums: a list of integers @return: find a majority number """ def majorityNumber(self, nums): # write your code here A = None count = 0 ...
2018-03-20 17:33:31 184
原创 lintcode 41.最大子数组
class Solution: def maxSubArray(self, nums): if nums is None or len(nums) == 0: return 0 maxSum = nums[0] minSum = 0 sum = 0 for num in nums: ...
2018-03-14 14:29:38 189
原创 lintcode 78.最长公共前缀
class Solution: """ @param strs: A list of strings @return: The longest common prefix """ def longestCommonPrefix(self, strs): # write your code here for element in strs: ...
2018-03-14 13:19:33 199
原创 lintcode 57.三数之和
class Solution: """ @param numbers: Give an array numbers of n integer @return: Find all unique triplets in the array which gives the sum of zero. """ def threeSum(self, numbers): ...
2018-03-13 16:01:27 202
原创 lintcode 12.带最小值操作的栈
class MinStack: def __init__(self): # do intialization if necessary self.stack=[] self.minstack=[] """ @param: number: An integer @return: nothing """ def pu...
2018-03-12 19:14:50 175
原创 lintcode 30.插入区间
"""Definition of Interval.class Interval(object): def __init__(self, start, end): self.start = start self.end = end"""class Solution: """ Insert a new interval into a sorted non...
2018-03-12 15:28:11 250
原创 lintcode 22.平面列表
class Solution(object): # @param nestedList a list, each element in the list # can be a list or integer, for example [1,2,[1,2]] # @return {int[]} a list of integer def flatten(self, nest...
2018-02-26 17:16:55 210
原创 lintcode 14.二分查找
'''超时了,很扎心'''class Solution: """ @param nums: The integer array. @param target: Target to find. @return: The first position of target. Position starts from 0. """ def binary...
2018-02-23 21:19:58 332
原创 lintcode 13.字符串查找
class Solution: """ @param: source: source string to be scanned. @param: target: target string containing the sequence of characters to match @return: a index to the first occurrence o...
2018-02-23 20:48:03 399
原创 lintcode 9.fizz buzz问题
class Solution: """ @param n: An integer @return: A list of strings. """ def fizzBuzz(self, n): # write your code here m="fizz" l="buzz" h="fizz buz.
2018-02-23 20:28:46 183
原创 arduino学习笔记
arduino初识:1 void setup() 这是在定义一个名字为setup 的函数2 pinMode(13, OUTPUT) 将13脚设置为输出output3 digitalWrite(13,HIGH) 将13脚设置为高水平4 voidloop{} 即一循环函数5 Serial.println() 输出6 for while 的用法与c语言相同7 静态变量 static8 注释 单行...
2018-02-21 12:10:54 409
原创 lintcode 8.旋转字符串
class Solution: """ @param str: An array of char @param offset: An integer @return: nothing """ def rotateString(self, s, offset): # write your code here newstr...
2018-02-21 10:18:59 245
原创 lintcode 6.合并并排序数组
class Solution: """ @param A: sorted integer array A @param B: sorted integer array B @return: A new sorted integer array """ def mergeSortedArray(self, A, B): # write ...
2018-02-21 09:12:33 190
原创 lintcode 3.统计数字
class Solution: """ @param: : An integer @param: : An integer @return: An integer denote the count of digit k in 1..n """ def digitCounts(self, k, n): # write your cod...
2018-02-20 14:30:54 255
原创 lintcode 2.尾部的零
class Solution: """ @param: n: An integer @return: An integer, denote the number of trailing zeros in n! """ def trailingZeros(self, n): # write your code here, try to do i...
2018-02-20 12:04:46 219
原创 lintcode 463.整数排序
class Solution: """ @param A: an integer array @return: nothing """ def sortIntegers(self, A): # write your code here return A.sort()
2018-02-20 10:59:00 279
原创 数据结构算法学习笔记1(欧几里得算法)
计算最大公因数god(m,n){int a;while(n>0){a=m%n;m=n;n=a}return n;}
2018-02-20 10:27:19 302
原创 lintcode 366.斐波那契数列
class Solution: """ @param n: an integer @return: an ineger f(n) """ def fibonacci(self, n): # write your code here n1=0 n2=1 if n==1: r...
2018-02-19 20:57:07 184
原创 lintcode 454.矩阵面积
class Rectangle: ''' * Define a constructor which expects two parameters width and height here. ''' # write your code here ''' * Define a public method `getArea` which ...
2018-02-19 20:54:57 345
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人