leetcode解题思路
MrJustin
欢迎来到我的博客跟我一起学习,我本科和硕士都是学习的计算机科学这个专业。在我毕业找工作的时候刷了大量的算法题目,这些知识和经验帮助我先后拿了八家国内外互联网的offer。但是并不是说大家都要刷这么多的题目,有时候一两百道的精刷也好过无脑的大量刷。我们一起学习,希望我的知识总结可以帮助到更多的小伙伴。也欢迎大家给我留言,一起探讨问题。
展开
-
LeetCode1466. Reorder Routes to Make All Paths Lead to the City Zero
[Med] LeetCode 1466. Reorder Routes to Make All Paths Lead to the City Zero链接: https://leetcode.com/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero/题目描述:There are n cities numbered from 0 to n-1 and n-1 roads such that there is only one原创 2020-06-01 07:03:45 · 354 阅读 · 0 评论 -
LeetCode 72. Edit Distance
[Hard] LeetCode 72. Edit Distance链接: https://leetcode.com/problems/edit-distance/题目描述:Given two words word1 and word2, find the minimum number of operationsrequired to convert word1 to word2.You have the following 3 operations permitted on a word:I原创 2020-06-01 04:58:20 · 195 阅读 · 0 评论 -
LeetCode 973. K Closest Points to Origin
[Med] LeetCode 973. K Closest Points to Origin链接: https://leetcode.com/submissions/detail/206164544/题目描述:We have a list of points on the plane. Find the K closest points to the origin (0, 0).(Here, the distance between two points on a plane is the Eu原创 2020-06-01 00:21:24 · 342 阅读 · 0 评论 -
LeetCode 1035. Uncrossed Lines
[Med] LeetCode 1035. Uncrossed Lines链接: https://leetcode.com/problems/uncrossed-lines/题目描述:We write the integers of A and B (in the order they are given) on two separate horizontal lines.Now, we may draw connecting lines: a straight line connecting t原创 2020-05-26 02:48:46 · 296 阅读 · 0 评论 -
LeetCode 1426 Counting Elements
[Med] LeetCode 1426 Counting Elements链接:题目描述:Given an integer array arr, count element x such that x + 1 is also in arr.If there’re duplicates in arr, count them seperately.Example 1:Input: arr = [1,2,3]Output: 2Explanation: 1 and 2 are counted c原创 2020-05-25 01:54:25 · 295 阅读 · 0 评论 -
LeetCode 1427: Perform String Shifts
[Easy] LeetCode 1427: Perform String Shifts链接: https://leetcode.com/problems/perform-string-shifts/题目描述:You are given a string s containing lowercase English letters, and a matrix shift, where shift[i] = [direction, amount]:direction can be 0 (for lef原创 2020-05-25 01:51:36 · 246 阅读 · 0 评论 -
LeetCode 1429. First Unique Number
[Med] LeetCode 1429. First Unique Number链接:题目描述:You have a queue of integers, you need to retrieve the first unique integer in the queue.Implement the FirstUnique class:FirstUnique(int[] nums) Initializes the object with the numbers in the queue.int原创 2020-05-25 01:46:43 · 683 阅读 · 0 评论 -
LeetCode 459. Repeated Substring Pattern
[Easy] LeetCode 459. Repeated Substring Pattern链接: https://leetcode.com/problems/repeated-substring-pattern/题目描述:Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together原创 2020-05-25 01:35:29 · 216 阅读 · 0 评论 -
LeetCode 986. Interval List Intersections
[Med] LeetCode 986. Interval List Intersections链接: https://leetcode.com/problems/interval-list-intersections/题目描述:Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order.Return the intersection of these two原创 2020-05-24 04:18:29 · 200 阅读 · 0 评论 -
LeetCode 1430. Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree
[Med] LeetCode 1430. Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree链接: https://leetcode.com/problems/check-if-a-string-is-a-valid-sequence-from-root-to-leaves-path-in-a-binary-tree/题目描述:Given a binary tree where each pa原创 2020-05-24 02:32:00 · 331 阅读 · 0 评论 -
LeetCode 1428. Leftmost Column with at Least a One
[Med] LeetCode (未知题号) Leftmost Column with at Least a One链接:题目描述:(This problem is an interactive problem.)A binary matrix means that all elements are 0 or 1. For each individual row of the matrix...原创 2020-05-24 02:15:26 · 1144 阅读 · 0 评论 -
LeetCode 402. Remove K Digits
[Med] LeetCode 402. Remove K Digits链接: https://leetcode.com/problems/remove-k-digits/题目描述: Given a non-negative integer num represented as a string, remove k digitsfrom the number so that the new number is the smallest possible.Example 1:Input: num原创 2020-05-14 06:08:46 · 160 阅读 · 0 评论 -
LeetCode 997. Find the Town Judge
[Easy] LeetCode 997. Find the Town Judge链接: https://leetcode.com/problems/find-the-town-judge/题目描述:In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge.If the town judge exists, then原创 2020-05-11 01:11:12 · 160 阅读 · 0 评论 -
LeetCode 1433. Check If a String Can Break Another String
[Med] LeetCode 1433. Check If a String Can Break Another String链接:题目描述:Example 1:Input: s1 = “abc”, s2 = “xya”Output: trueExplanation: “ayx” is a permutation of s2=“xya” which can break to string “abc” which is a permutation of s1=“abc”.Example 2原创 2020-05-11 00:34:06 · 284 阅读 · 1 评论 -
LeetCode 826. Most Profit Assigning Work
[Med] LeetCode 826. Most Profit Assigning Work链接: https://leetcode.com/problems/most-profit-assigning-work/题目描述:We have jobs: difficulty[i] is the difficulty of the ith job, and profit[i] is the profit of the ith job.Now we have some workers. worker[i原创 2020-05-10 07:43:37 · 204 阅读 · 0 评论 -
LeetCode 367. Valid Perfect Square
[Easy] LeetCode 367. Valid Perfect Square链接: https://leetcode.com/problems/valid-perfect-square/题目描述:Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in library function原创 2020-05-10 06:57:34 · 133 阅读 · 0 评论 -
LeetCode 383. Ransom Note
[Easy] LeetCode 383. Ransom Note链接: https://leetcode.com/problems/ransom-note/题目描述:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a funct...原创 2020-05-04 04:10:27 · 110 阅读 · 0 评论 -
Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree
[Med] LeetCode Check If a String Is a Valid Sequence from Root to Leaves Path in a Binary Tree链接:题目描述:Given a binary tree where each path going from the root to any leaf form a valid sequence, che...原创 2020-05-02 12:35:42 · 177 阅读 · 0 评论 -
LeetCode 1143. Longest Common Subsequence
[Med] LeetCode 1143. Longest Common Subsequence链接: https://leetcode.com/problems/longest-common-subsequence/题目描述:Given two strings text1 and text2, return the length of their longest common subseq...原创 2020-04-26 23:58:25 · 243 阅读 · 0 评论 -
LeetCode 855. Exam Room
[Med] LeetCode 855. Exam Room链接: https://leetcode.com/problems/exam-room/题目描述:In an exam room, there are N seats in a single row, numbered 0, 1, 2, …, N-1.When a student enters the room, they mu...原创 2020-04-26 05:25:19 · 331 阅读 · 0 评论 -
LeetCode 849. Maximize Distance to Closest Person
[Easy] LeetCode 849. Maximize Distance to Closest Person链接: https://leetcode.com/problems/maximize-distance-to-closest-person/题目描述:In a row of seats, 1 represents a person sitting in that seat, an...原创 2020-04-26 02:58:04 · 173 阅读 · 0 评论 -
LeetCode 146. LRU Cache
[Med] LeetCode 146. LRU Cache链接: https://leetcode.com/problems/lru-cache/题目描述:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:...原创 2020-04-25 02:17:36 · 120 阅读 · 0 评论 -
LeetCode 1155. Number of Dice Rolls With Target Sum
[Med] LeetCode 1155. Number of Dice Rolls With Target Sum链接: https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/题目描述:You have d dice, and each die has f faces numbered 1, 2, …, f....原创 2020-04-24 07:50:32 · 304 阅读 · 0 评论 -
LeetCode 201. Bitwise AND of Numbers Range
[Med] LeetCode 201. Bitwise AND of Numbers Range链接: https://leetcode.com/problems/bitwise-and-of-numbers-range/题目描述:Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwis...原创 2020-04-24 06:27:20 · 177 阅读 · 0 评论 -
LeetCode 1021. Remove Outermost Parentheses
[Easy] LeetCode 1021. Remove Outermost Parentheses链接: https://leetcode.com/problems/remove-outermost-parentheses/题目描述:A valid parentheses string is either empty (""), “(” + A + “)”, or A + B, wher...原创 2020-04-23 08:49:32 · 195 阅读 · 0 评论 -
LeetCode 938. Range Sum of BST
[Med] LeetCode 938. Range Sum of BST链接: https://leetcode.com/problems/range-sum-of-bst/题目描述:Given the root node of a binary search tree, return the sum of values of all nodes with value between L ...原创 2020-04-23 06:43:10 · 156 阅读 · 0 评论 -
LeetCode 1218. Longest Arithmetic Subsequence of Given Difference
[Med] LeetCode 1218. Longest Arithmetic Subsequence of Given Difference链接: https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference/题目描述:Given an integer array arr and an i...原创 2020-04-23 06:08:11 · 256 阅读 · 0 评论 -
LeetCode 1325. Delete Leaves With a Given Value
[Med] LeetCode 1325. Delete Leaves With a Given Value链接: https://leetcode.com/problems/delete-leaves-with-a-given-value/题目描述:Given a binary tree root and an integer target, delete all the leaf nod...原创 2020-04-23 05:41:32 · 227 阅读 · 0 评论 -
LeetCode 560. Subarray Sum Equals K
[Med] LeetCode 560. Subarray Sum Equals K链接: https://leetcode.com/problems/subarray-sum-equals-k/题目描述:Given an array of integers and an integer k, you need to find the total number of continuous s...原创 2020-04-23 05:19:57 · 171 阅读 · 0 评论 -
LeetCode 1340. Jump Game V
[Hard] LeetCode Jump Game V链接: https://leetcode.com/problems/jump-game-v/题目描述:Given an array of integers arr and an integer d. In one step you can jump from index i to index:i + x where: i + x &l...原创 2020-04-22 13:19:29 · 341 阅读 · 0 评论 -
LeetCode 1342. Number of Steps to Reduce a Number to Zero
[Easy] LeetCode 1342. Number of Steps to Reduce a Number to Zero链接: https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/题目描述:Given a non-negative integer num, return the numbe...原创 2020-04-22 13:08:54 · 206 阅读 · 0 评论 -
LeetCode 1347. Minimum Number of Steps to Make Two Strings Anagram
[Med] LeetCode 1347. Minimum Number of Steps to Make Two Strings Anagram链接: https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram/题目描述:Given two equal-size strings s an...原创 2020-04-22 12:20:32 · 460 阅读 · 0 评论 -
LeetCode 1254. Number of Closed Islands
[Med] 1254. Number of Closed IslandsLeetCode链接: https://leetcode.com/problems/number-of-closed-islands/题目描述:Given a 2D grid consists of 0s (land) and 1s (water). An island is a maximal 4-directio...原创 2020-04-22 07:57:36 · 255 阅读 · 0 评论 -
LeetCode 1419. Minimum Number of Frogs Croaking
[Med] LeetCode 1419. Minimum Number of Frogs Croaking链接: https://leetcode.com/problems/minimum-number-of-frogs-croaking/题目描述:Given the string croakOfFrogs, which represents a combination of the st...原创 2020-04-22 07:42:43 · 776 阅读 · 0 评论 -
LeeCode 1418. Display Table of Food Orders in a Restaurant
[Med] LeetCode 1418. Display Table of Food Orders in a Restaurant链接: https://leetcode.com/problems/display-table-of-food-orders-in-a-restaurant/Medium:题目描述:Given the array orders, which represent...原创 2020-04-21 09:47:56 · 505 阅读 · 0 评论 -
LeetCode 1417. Reformat The String
[Easy] LeetCode 1417. Reformat The String链接: https://leetcode.com/problems/reformat-the-string/题目描述:Given alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English le...原创 2020-04-21 08:26:28 · 396 阅读 · 0 评论 -
LeetCode 题目讲解集合
LeetCode 题目集合题号难度正文1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...原创 2020-04-21 07:38:08 · 218 阅读 · 0 评论 -
LeetCode 1008. Construct Binary Search Tree from Preorder Traversal
[Med] LeetCode 1008. Construct Binary Search Tree from Preorder Traversal加粗样式链接:https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/题目描述:Return the root node of a b...原创 2020-04-21 07:17:28 · 257 阅读 · 0 评论 -
LeetCode 1365. How Many Numbers Are Smaller Than the Current Number
[Easy] LeetCode链接:https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/题目描述Given the array nums, for each nums[i] find out how many numbers in the array are smaller t...原创 2020-04-20 06:12:39 · 342 阅读 · 0 评论 -
Leetcode 1376. Time Needed to Inform All Employees
[Med] LeetCode 1376. Time Needed to Inform All Employees链接:https://leetcode.com/problems/time-needed-to-inform-all-employees/题目描述A company has n employees with a unique ID for each employee from 0...原创 2020-04-20 06:08:49 · 793 阅读 · 0 评论