提升
Sino1996
Talk is cheap, show me the code
展开
-
10.12笔记之hive入门基础函数
1.CONCAT(str1,str2,…)返回结果为连接参数产生的字符串。如有任何一个参数为NULL ,则返回值为 NULL。可以有一个或多个参数。(若其中有null则返回null)2.如何指定参数之间的分隔符使用函数CONCAT_WS()。使用语法为:CONCAT_WS(separator,str1,str2,…)CONCAT_WS() 代...原创 2019-10-12 17:39:30 · 141 阅读 · 0 评论 -
8.15笔记
61. 旋转链表class Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if not head or k == 0 ...原创 2019-08-15 12:52:44 · 74 阅读 · 0 评论 -
leetcode第149场周赛(8.11)
1154. 一年中的第几天给你一个按 YYYY-MM-DD 格式表示日期的字符串date,请你计算并返回该日期是当年的第几天。通常情况下,我们认为 1 月 1 日是每年的第 1 天,1 月 2 日是每年的第 2 天,依此类推。每个月的天数与现行公元纪年法(格里高利历)一致。class Solution(object): def ordinalOfDate(self, dat...原创 2019-08-11 13:15:30 · 309 阅读 · 0 评论 -
8.11笔记
80. 删除排序数组中的重复项 IIclass Solution(object): def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ i = 0 for num in nums: ...原创 2019-08-11 10:07:10 · 51 阅读 · 0 评论 -
8.20笔记
75. 颜色分类(不能用内置函数,利用三指针的方法) def sortColors(self, nums): """ :type nums: List[int] :rtype: None Do not return anything, modify nums in-place instead. """ re...原创 2019-08-20 10:35:32 · 60 阅读 · 0 评论 -
8.10笔记
105. 从前序与中序遍历序列构造二叉树(递归)class Solution(object): def buildTree(self, preorder, inorder): """ :type preorder: List[int] :type inorder: List[int] :rtype: TreeNode ...原创 2019-08-10 12:18:55 · 172 阅读 · 0 评论 -
8.14笔记
46. 全排列class Solution(object): def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ res = [] self.dfs(nums,[],res) ...原创 2019-08-14 12:40:04 · 76 阅读 · 0 评论 -
8.19笔记
143. 重排链表class Solution(object): def reorderList(self, head): """ :type head: ListNode :rtype: None Do not return anything, modify head in-place instead. """ ...原创 2019-08-19 10:25:18 · 186 阅读 · 0 评论 -
8.7笔记
524. 通过删除字母匹配到字典里最长单词class Solution(object): def findLongestWord(self, s, d): """ :type s: str :type d: List[str] :rtype: str """ d.sort(key = la...原创 2019-08-07 12:21:13 · 74 阅读 · 0 评论 -
8.9笔记
129. 求根到叶子节点数字之和class Solution(object): def sumNumbers(self, root): """ :type root: TreeNode :rtype: int """ self.res = 0 if not root: ...原创 2019-08-09 10:36:25 · 49 阅读 · 0 评论 -
8.2笔记
477. 汉明距离总和class Solution: def totalHammingDistance(self, nums: List[int]) -> int: sum1 = 0 for i in range(31): c1,c2 = 0,0 for n in nums: ...原创 2019-08-02 13:41:46 · 71 阅读 · 0 评论 -
8.8笔记
526. 优美的排列class Solution(object): def countArrangement(self, N): """ :type N: int :rtype: int """ res = [False]*N self.result = 0 def dps...原创 2019-08-08 18:40:28 · 157 阅读 · 0 评论 -
8.6笔记
回顾:300. 最长上升子序列第一种方法(dp)class Solution(object): def lengthOfLIS(self, nums): """ :type nums: List[int] :rtype: int """ if not nums: retur...原创 2019-08-06 11:00:24 · 78 阅读 · 0 评论 -
7.28笔记(第147场周赛前两道)
今天第二次参加周赛,能做出两道题很开心了,还记得第一次参加周赛时一道没写出来尴尬,继续加油。5139. 第 N 个泰波那契数(很简单,递归会超时)class Solution(object): def tribonacci(self, n): """ :type n: int :rtype: int """ ...原创 2019-07-28 14:18:16 · 124 阅读 · 0 评论 -
8.1笔记
462. 最少移动次数使数组元素相等 IIclass Solution: def minMoves2(self, nums: List[int]) -> int: nums.sort() res = 0 index = len(nums)//2 for i in range(len(nums)): ...原创 2019-08-01 10:56:45 · 85 阅读 · 0 评论 -
7.27笔记
406. 根据身高重建队列class Solution(object): def reconstructQueue(self, people): a = sorted(people,key = lambda x: (-x[0],x[1])) #按照身高降序k升序进行排列 res = [] for each in a: ...原创 2019-07-27 11:22:48 · 464 阅读 · 0 评论 -
8.12笔记
近期都是回顾一下以前做过的题:134. 加油站class Solution(object): def canCompleteCircuit(self, gas, cost): """ :type gas: List[int] :type cost: List[int] :rtype: int """...原创 2019-08-12 10:26:01 · 67 阅读 · 0 评论 -
8.24笔记
435. 无重叠区间class Solution(object): def eraseOverlapIntervals(self, intervals): """ :type intervals: List[List[int]] :rtype: int """ l = len(intervals) ...原创 2019-08-24 16:05:11 · 113 阅读 · 0 评论 -
8.25笔记
209. 长度最小的子数组class Solution(object): def minSubArrayLen(self, s, nums): """ :type s: int :type nums: List[int] :rtype: int """ a,b,k = 0,0,float(...原创 2019-08-25 14:15:11 · 94 阅读 · 0 评论 -
9.3笔记
53. 最大子序和class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ for i in range(1,len(nums)): nums[i] ...原创 2019-09-03 10:18:11 · 167 阅读 · 0 评论 -
9.2笔记
111. 二叉树的最小深度class Solution(object): def minDepth(self, root): """ :type root: TreeNode :rtype: int """ if not root: return 0 if not ...原创 2019-09-02 09:47:11 · 116 阅读 · 0 评论 -
8.31笔记
105. 从前序与中序遍历序列构造二叉树class Solution(object): def buildTree(self, preorder, inorder): """ :type preorder: List[int] :type inorder: List[int] :rtype: TreeNode ...原创 2019-08-31 13:38:51 · 94 阅读 · 0 评论 -
8.30笔记
215. 数组中的第K个最大元素(快排思路,每次随机取数,把比该数大的放前面)class Solution(object): def findKthLargest(self, nums, k): """ :type nums: List[int] :type k: int :rtype: int """...原创 2019-08-30 10:30:42 · 89 阅读 · 0 评论 -
8.29笔记
63. 不同路径 IIclass Solution(object): def uniquePathsWithObstacles(self, obstacleGrid): """ :type obstacleGrid: List[List[int]] :rtype: int """ res = len(ob...原创 2019-08-29 10:44:46 · 71 阅读 · 0 评论 -
8.28笔记
216. 组合总和 IIIclass Solution(object): def combinationSum3(self, k, n): """ :type k: int :type n: int :rtype: List[List[int]] """ res = [] ...原创 2019-08-28 12:21:23 · 69 阅读 · 0 评论 -
8.27笔记
287. 寻找重复数class Solution(object): def findDuplicate(self, nums): """ :type nums: List[int] :rtype: int """ slow ,fast ,res = 0 ,0 ,0 while True:...原创 2019-08-27 10:29:50 · 81 阅读 · 0 评论 -
8.26笔记
33. 搜索旋转排序数组class Solution(object): def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ l = 0 if ...原创 2019-08-26 14:24:01 · 76 阅读 · 0 评论 -
第150周周赛(前两题)
总的来说这周的题目较为简单,前两道完全是拼手速的题目。5048. 拼写单词给你一份『词汇表』(字符串数组)words和一张『字母表』(字符串)chars。假如你可以用chars中的『字母』(字符)拼写出 words中的某个『单词』(字符串),那么我们就认为你掌握了这个单词。注意:每次拼写时,chars 中的每个字母都只能用一次。返回词汇表words中你掌握的所有...原创 2019-08-18 14:39:32 · 93 阅读 · 0 评论 -
8.17笔记
450. 删除二叉搜索树中的节点class Solution(object): def deleteNode(self, root, key): """ :type root: TreeNode :type key: int :rtype: TreeNode """ if not root...原创 2019-08-17 16:35:27 · 82 阅读 · 0 评论 -
8.22笔记
152. 乘积最大子序列class Solution(object): def maxProduct(self, nums): """ :type nums: List[int] :rtype: int """ min_list = [0 for _ in range(len(nums))] ...原创 2019-08-22 10:59:59 · 60 阅读 · 0 评论 -
8.13笔记
230. 二叉搜索树中第K小的元素class Solution(object): def kthSmallest(self, root, k): """ :type root: TreeNode :type k: int :rtype: int """ stack = [] ...原创 2019-08-13 10:52:30 · 73 阅读 · 0 评论 -
8.16笔记
147. 对链表进行插入排序class Solution(object): def insertionSortList(self, head): """ :type head: ListNode :rtype: ListNode """ res = p = ListNode(0) res....原创 2019-08-16 12:29:29 · 60 阅读 · 0 评论 -
8.21笔记
445. 两数相加 IIclass Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ if not l1 and...原创 2019-08-21 13:42:08 · 77 阅读 · 0 评论 -
8.5笔记
513. 找树左下角的值(其实就是按层遍历二叉树)class Solution(object): def findBottomLeftValue(self, root): """ :type root: TreeNode :rtype: int """ if not root: r...原创 2019-08-05 09:59:25 · 77 阅读 · 0 评论 -
7.23笔记
334. 递增的三元子序列class Solution: def increasingTriplet(self, nums: List[int]) -> bool: a = b = float('inf') for n in nums: if n <= a: a = n ...原创 2019-07-23 10:59:36 · 71 阅读 · 0 评论 -
7.11笔记
复习322.零钱兑换:class Solution: def coinChange(self, coins: List[int], amount: int) -> int: dp = [amount+1]*(amount+1) dp[0] = 0 for i in range(1,amount+1): fo...原创 2019-07-11 11:30:02 · 75 阅读 · 0 评论 -
7.5笔记
700.二叉搜索树中的搜索(简单的二叉搜索树查找,当前值大于val向左查找,小于val则向右查找):class Solution: def searchBST(self, root: TreeNode, val: int) -> TreeNode: if not root: return None while root:...原创 2019-07-05 17:08:12 · 66 阅读 · 0 评论 -
7.15笔记
2019年7月15日,祝自己生日快乐。236. 二叉树的最近公共祖先class Solution: def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode': if not root or root == p or root == ...原创 2019-07-15 10:35:32 · 61 阅读 · 0 评论 -
7.14笔记
228. 汇总区间class Solution: def summaryRanges(self, nums: List[int]) -> List[str]: if not nums: return [] res = [] a = b = 0 for i in range(1,len(num...原创 2019-07-14 11:57:34 · 68 阅读 · 0 评论 -
7.10笔记
724.寻找数组的中心索引class Solution: def pivotIndex(self, nums: List[int]) -> int: all_sum = sum(nums) res = 0 for i in range(len(nums)): if res*2 + nums[i] == al...原创 2019-07-10 10:16:53 · 99 阅读 · 0 评论