源式羽语

有志于学,不赞美,不责难,只求了解认识。

54. Spiral Matrix

class Solution(object):     def spiralOrder(self, matrix):         """         :type matrix: List[List[int]]         :rtype: List[...

2017-05-19 17:08:40

阅读数:174

评论数:0

34. Search for a Range

class Solution(object):     def searchRange(self, nums, target):         """         :type nums: List[int]         :type target: i...

2017-05-19 11:34:23

阅读数:136

评论数:0

35. Search Insert Position

class Solution(object):     def searchInsert(self, nums, target):         """         :type nums: List[int]         :type target: ...

2017-05-19 10:10:16

阅读数:107

评论数:0

[leetcode 561]Array Partition I

题目:求2n个数字的数组组成n对中的每个小数字之和最大 nums.sort()         return sum(nums[::2])

2017-05-18 15:31:36

阅读数:130

评论数:0

[leetcode 560]Subarray Sum Equals K

题目:求连续子集和为k的个数代码出自:https://discuss.leetcode.com/topic/88041/super-simple-pythonclass Solution(object):    def subarraySum(self, nums, k):        &...

2017-05-18 15:13:18

阅读数:353

评论数:0

[leetcode462] Minimum Moves to Equal Array Elements II

class Solution(object):     def minMoves2(self, nums):         """         :type nums: List[int]         :rtype: int         &quo...

2017-05-17 16:40:01

阅读数:180

评论数:0

[return sum(nums)-min(nums)*len(nums)leetcode453】 Minimum Moves to Equal Array Elements

题意: 每次移动可以加1,移动的时候只能移动n-1个,需要移动多少次可以使得数组值都相等 python :return sum(nums)-min(nums)*len(nums) class Solution(object):     def minMoves(self, nums): ...

2017-05-17 16:10:38

阅读数:148

评论数:0

[leetcode 448]Find All Numbers Disappeared in an Array

同442一样,只是判断条件不一样 class Solution(object):     def findDisappearedNumbers(self, nums):         """         :type nums: List[int]...

2017-05-17 15:16:26

阅读数:193

评论数:0

330. Patching Array

class Solution(object):     def minPatches(self, nums, n):         """         :type nums: List[int]         :type n: int        ...

2017-05-15 11:55:02

阅读数:129

评论数:0

[leetcode238]Product of Array Except Self

class Solution(object):     def productExceptSelf(self, nums):         """         :type nums: List[int]         :rtype: List[int]...

2017-05-15 10:40:33

阅读数:95

评论数:0

leetcode154Find Minimum in Rotated Sorted Array II

class Solution(object):     def findMin(self, nums):         """         :type nums: List[int]         :rtype: int         "...

2017-05-11 12:53:46

阅读数:128

评论数:0

letcode153Find Minimum in Rotated Sorted Array

class Solution(object):     def findMin(self, nums):         """         :type nums: List[int]         :rtype: int         "...

2017-05-11 12:41:19

阅读数:106

评论数:0

[leetcode 53]Maximum Subarray

class Solution(object):     def maxSubArray(self, nums):         """         :type nums: List[int]         :rtype: int         &q...

2017-05-09 21:46:32

阅读数:96

评论数:0

27. Remove Element

题目:数组中的重复元素都删掉,且返回长度 要求:不可另外开空间 解题思路:用两个指针,一个指开头,一个指结尾,当开头的与所给值相同时把结尾的值赋值过来,尾指针向前 class Solution(object):     def removeElement(self, nums, val):    ...

2017-05-08 21:34:17

阅读数:118

评论数:0

26 Remove Duplicates from Sorted Array

题目:删除有序数组中的重复元素,返回长度 要求:不能重新分配内存空间 解题: class Solution(object):     def removeDuplicates(self, nums):         """         :type num...

2017-05-08 20:41:14

阅读数:92

评论数:0

Leetcode 80]Remove Duplicates from Sorted Array II

class Solution(object):     def removeDuplicates(self, nums):         """         :type nums: List[int]         :rtype: int      ...

2017-05-05 21:31:25

阅读数:116

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭