- 博客(38)
- 收藏
- 关注
原创 LeetCode 109. Convert Sorted List to Binary Search Tree(二叉树)
题目来源:https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/问题描述109.Convert Sorted List to Binary Search TreeMediumGiven a singly linked list where elements are sorted in asc...
2019-05-30 00:06:21 115
原创 LeetCode 106. Construct Binary Tree from Inorder and Postorder Traversal(二叉树)
题目来源:https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/问题描述106.Construct Binary Tree from Inorder and Postorder TraversalMediumGiven inorder and postord...
2019-05-28 00:26:56 91
原创 LeetCode 104. Maximum Depth of Binary Tree(二叉树)
题目来源:https://leetcode.com/problems/maximum-depth-of-binary-tree/问题描述104.Maximum Depth of Binary TreeEasyGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes ...
2019-05-26 15:11:02 117
原创 LeetCode 101. Symmetric Tree(二叉树)
题目来源:https://leetcode.com/problems/symmetric-tree/问题描述101.Symmetric TreeEasyGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this b...
2019-05-26 14:21:51 100
原创 LeetCode 103. Binary Tree Zigzag Level Order Traversal(二叉树)
题目来源:https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/问题描述103.Binary Tree Zigzag Level Order TraversalMediumGiven a binary tree, return thezigzag level ordertraversal ...
2019-05-26 14:03:48 112
原创 LeetCode 102. Binary Tree Level Order Traversal(二叉树bfs)
题目来源:https://leetcode.com/problems/binary-tree-level-order-traversal/问题描述102.Binary Tree Level Order TraversalMediumGiven a binary tree, return thelevel ordertraversal of its nodes' values. ...
2019-05-25 21:36:03 121
原创 LeetCode100. Same Tree(二叉树)
Same TreeCategory Difficulty Likes Dislikesalgorithms Easy (49.97%) 1116 34TagsCompaniesGiven two binary trees, write a function to check if they are the same or not.Two binary trees are conside...
2019-05-23 17:34:52 92
原创 LeetCode 98. Validate Binary Search Tree(二叉树)
Validate Binary Search TreeMediumGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with key...
2019-05-22 21:54:44 138
原创 LeetCode 94. Binary Tree Inorder Traversal(二叉树中序遍历)
Binary Tree Inorder TraversalGiven a binary tree, return the inorder traversal of its nodes’ values.Example:Input: [1,null,2,3]12/3Output: [1,3,2]题意输出二叉树的中序遍历思路递归代码/* * @lc app=leetcod...
2019-05-21 13:36:37 124
原创 LeetCode 93. Restore IP Addresses(深搜剪枝)
题目来源:https://leetcode.com/problems/restore-ip-addresses/问题描述93.Restore IP AddressesMediumGiven a string containing only digits, restore it by returning all possible valid IP address combinati...
2019-05-20 11:50:50 340
原创 LeetCode 92. Reverse Linked List II(链表)
题目来源:https://leetcode.com/problems/reverse-linked-list-ii/问题描述92.Reverse Linked List IIMediumReverse a linked list from positionmton. Do it in one-pass.Note:1 ≤m≤n≤ length of list....
2019-05-19 11:41:02 126
原创 LeetCode 99. Recover Binary Search Tree(二叉树)
题目来源:https://leetcode.com/problems/recover-binary-search-tree/问题描述99.Recover Binary Search TreeHardTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without...
2019-05-18 11:17:33 96
原创 LeetCode 230. Kth Smallest Element in a BST(二叉树)
Kth Smallest Element in a BSTMediumGiven a binary search tree, write a function kth Smallest to find the kth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST’s total eleme...
2019-05-17 12:39:40 224
原创 LeetCode 91. Decode Ways(递推)
题目来源:https://leetcode.com/problems/decode-ways/问题描述91.Decode WaysMediumA message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...
2019-05-16 11:26:19 174
原创 LeetCode 90. Subsets II
题目来源:https://leetcode.com/problems/subsets-ii/问题描述90.Subsets IIMediumGiven a collection of integers that might contain duplicates,nums, return all possible subsets (the power set).Note:Th...
2019-05-16 10:39:18 136
原创 LeetCode 88. Merge Sorted Array
Merge Sorted ArrayEasyGiven two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectivel...
2019-05-14 14:11:58 99
原创 Python按行读取大文件
在工作中遇到一个需求,需要用Python脚本读取一个13G的文件,把每行的记录写入redis。由于机器的内存只有8G,所以不能一次将磁盘上的文件全部读入内存,需要一行一行读取文件。Python按行读取文件主要是使用file.readline方法或者利用file对象的迭代器性质,而file.readlines方法则是一次把所有内容从磁盘读入内存。当内存足够时,file.readlines方法显然...
2019-05-13 23:37:09 7375 3
原创 LeetCode 89. Gray Code(格雷码生成)
题目来源:https://leetcode.com/problems/gray-code/问题描述89.Gray CodeMediumThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integern...
2019-05-13 14:46:45 330
原创 LeetCode 97. Interleaving String(动态规划)
题目来源:https://leetcode.com/problems/interleaving-string/问题描述97.Interleaving StringHardGivens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.Example 1:Input: s1 = "aa...
2019-05-12 11:18:44 120
原创 LeetCode 86. Partition List(链表)
题目来源:https://leetcode.com/problems/partition-list/问题描述86.Partition ListMediumGiven a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or ...
2019-05-11 11:24:24 186
原创 LeetCode 85. Maximal Rectangle
题目来源:https://leetcode.com/problems/maximal-rectangle/问题描述85.Maximal RectangleHardGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return it...
2019-05-10 11:47:28 128
原创 LeetCode 83. Remove Duplicates from Sorted List(链表)
题目来源:https://leetcode.com/problems/remove-duplicates-from-sorted-list/问题描述83.Remove Duplicates from Sorted ListEasyGiven a sorted linked list, delete all duplicates such that each element app...
2019-05-09 23:40:16 92
原创 LeetCode 82. Remove Duplicates from Sorted List II(链表)
题目来源:https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/问题描述82.Remove Duplicates from Sorted List IIMediumGiven a sorted linked list, delete all nodes that have duplicate num...
2019-05-09 23:25:41 140
原创 LeetCode 84. Largest Rectangle in Histogram(单调栈)
题目来源:https://leetcode.com/problems/largest-rectangle-in-histogram/问题描述84.Largest Rectangle in HistogramHardGivennnon-negative integers representing the histogram's bar height where the widt...
2019-05-09 21:21:11 186
原创 Vim批量注释与取消注释
Vim命令模式下注释与批量注释的命令分别为(以Python为例,Python的行注释为#)::{begin},{end}s/^/#/g:{begin},{end}s/^#//g其中begin和end分别是需要注释的开始行号和结束行号.理解这条命令需要了解Vim替换命令,Vim替换命令格式如下:{begin},{end}s/{source}/{target}/{flag}其中begi...
2019-05-08 21:28:25 208
原创 LeetCode 81. Search in Rotated Sorted Array II(二分)
Search in Rotated Sorted Array IIMediumSuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).You are gi...
2019-05-08 14:56:52 146
原创 LeetCode 80. Remove Duplicates from Sorted Array II
Remove Duplicates from Sorted Array IIMediumGiven a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.Do not allocate extra spa...
2019-05-07 14:01:29 92
原创 LeetCode 79. Word Search (dfs)
Word SearchMediumGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontal...
2019-05-06 13:44:04 124
原创 LeetCode 78. Subsets(枚举)
SubsetsMediumGiven a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[...
2019-05-05 17:10:00 153
原创 推荐系统算法综述
推荐系统算法综述:从LR到FM再到DNN最近在看推荐系统,主要学习了LR,FM,FFM和DNN四种常用的推荐算法。本文打算对推荐系统的问题背景和这些常见算法写一个简单的综述,由于不是专门研究推荐系统的,只是书写一下个人理解,恐怕会有颇多谬误,望各位大佬批评指正。问题背景首先,计算广告/推荐系统本质上解决的是同样一个问题,即给定一个展示平台和一个广告/一个用户和一个待推荐的物品,该广告/该物品...
2019-05-04 23:23:38 1593
原创 LeetCode 77. Combinations(递归)
题目来源:https://leetcode.com/problems/combinations/问题描述77.CombinationsMediumGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.Example:Input:n = 4, k =...
2019-05-04 15:49:04 164
原创 LeetCode 75. Sort Colors(双指针)
题目来源:https://leetcode.com/problems/sort-colors/问题描述75.Sort ColorsMediumGiven an array withnobjects colored red, white or blue, sort themin-placeso that objects of the same color are adjac...
2019-05-04 13:42:46 126
原创 LeetCode 74. Search a 2D Matrix(二分)
题目来源:https://leetcode.com/problems/search-a-2d-matrix/问题描述74.Search a 2D MatrixMediumWrite an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following p...
2019-05-04 13:06:31 114
原创 LeetCode 76. Minimum Window Substring(滑窗)
题目来源:https://leetcode.com/problems/minimum-window-substring/问题描述76.Minimum Window SubstringHardGiven a string S and a string T, find the minimum window in S which will contain all the charact...
2019-05-03 21:15:24 116
原创 LeetCode 70. Climbing Stairs(递推)
题目来源:https://leetcode.com/problems/climbing-stairs/问题描述70.Climbing StairsEasyYou are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. ...
2019-05-02 22:01:03 151
原创 LeetCode 69. Sqrt(x)(二分)
题目来源:https://leetcode.com/problems/sqrtx/问题描述69.Sqrt(x)EasyImplementint sqrt(int x).Compute and return the square root ofx, wherexis guaranteed to be a non-negative integer.Since the ...
2019-05-02 21:10:25 95
原创 LeetCode 71. Simplify Path(栈)
题目来源:https://leetcode.com/problems/simplify-path/问题描述71.Simplify PathMediumGiven anabsolute pathfor a file (Unix-style), simplify it. Or in other words, convert it to thecanonical path....
2019-05-02 15:38:30 123
原创 LeetCode 73. Set Matrix Zeroes
题目来源:https://leetcode.com/problems/set-matrix-zeroes/问题描述73.Set Matrix ZeroesMediumGiven amxnmatrix, if an element is 0, set its entire row and column to 0. Do itin-place.Example 1:I...
2019-05-01 15:36:10 200
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人