- 博客(137)
- 收藏
- 关注
原创 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
139
原创 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
166
原创 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
115
原创 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
91
原创 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
87
原创 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
原创 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
原创 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
80
原创 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
原创 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
原创 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
原创 8.23笔记
376. 摆动序列class Solution(object): def wiggleMaxLength(self, nums): """ :type nums: List[int] :rtype: int """ if len(nums)<2: return len(nums)...
2019-08-23 13:54:00
93
原创 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
原创 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
原创 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
原创 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
原创 第150周周赛(前两题)
总的来说这周的题目较为简单,前两道完全是拼手速的题目。5048. 拼写单词给你一份『词汇表』(字符串数组)words和一张『字母表』(字符串)chars。假如你可以用chars中的『字母』(字符)拼写出 words中的某个『单词』(字符串),那么我们就认为你掌握了这个单词。注意:每次拼写时,chars 中的每个字母都只能用一次。返回词汇表words中你掌握的所有...
2019-08-18 14:39:32
93
原创 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
原创 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
原创 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
原创 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
75
原创 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
原创 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
原创 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
307
原创 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
原创 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
原创 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
原创 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
155
原创 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
原创 关于牛客笔试时初始化输入(python链表初始化和列表初始化)
1.只有一个整数:a = int(input)2.一行多个整数并用空格分开:a,b = map(int,input().split())3.数据较多时可用 列表存储:num = list(map(int,input().split()))4.关于初始化链表:class Node: def __init__(self,x): self.val = x ...
2019-08-06 16:33:46
1002
原创 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
原创 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
原创 第148周周赛
第一题:递减元素使数组呈锯齿状给你一个整数数组nums,每次 操作会从中选择一个元素并 将该元素的值减少1。如果符合下列情况之一,则数组A就是 锯齿数组:每个偶数索引对应的元素都大于相邻的元素,即A[0] > A[1] < A[2] > A[3] < A[4] > ... 或者,每个奇数索引对应的元素都大于相邻的元素,即A[0] &l...
2019-08-04 13:29:10
215
转载 关于GitHub上上传自己的项目过程(转载)
作者写的很好,照着做很快的成功了https://blog.csdn.net/m0_37725003/article/details/80904824
2019-08-03 17:06:44
73
原创 8.3笔记
503. 下一个更大元素 IIclass Solution: def nextGreaterElements(self, nums: List[int]) -> List[int]: l = len(nums) res = [-1 for _ in range(l)] stack = [] double_nums ...
2019-08-03 14:50:26
104
原创 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
原创 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
原创 7.31笔记
451. 根据字符出现频率排序class Solution: def frequencySort(self, s: str) -> str: res = collections.Counter(s) return ''.join(c*res[c] for c in sorted(res, key = res.get)[::-1])452. 用...
2019-07-31 10:39:08
75
原创 7.30笔记
445. 两数相加 IIclass Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: if not l1 and not l2: return None a = 0 b = 0 l3 = L...
2019-07-30 10:45:32
83
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人