LeetCode刷题
每天的每一天
这个作者很懒,什么都没留下…
展开
-
LeetCode之1. Two Sum
Given an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not use thesame...原创 2018-12-21 17:43:36 · 146 阅读 · 0 评论 -
LeetCode之83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.Example 1:Input: 1->1->2Output: 1->2Example 2:Input: 1->1->2->3->3Output: 1-...原创 2019-03-08 23:33:21 · 127 阅读 · 0 评论 -
LeetCode之62. Unique Paths
A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo...原创 2019-03-04 11:09:55 · 186 阅读 · 0 评论 -
LeetCode之17. Letter Combinations of a Phone Number
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note:A leaf is a node with no children.Example:...原创 2019-03-07 00:21:51 · 154 阅读 · 0 评论 -
LeetCode之72. Edit Distance
Given two wordsword1andword2, find the minimum number of operations required to convertword1toword2.You have the following 3 operations permitted on a word:Insert a character Delete a chara...原创 2019-03-14 23:40:47 · 145 阅读 · 0 评论 -
LeetCode之143. Reorder List
Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You maynotmodify the values in the list's nodes, only nodes itself may be changed.Example 1:Given 1->2-...原创 2019-03-19 22:43:39 · 125 阅读 · 0 评论 -
LeetCode之114. Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \ \3 4 6The flattened tree should look like:1 \ 2 \ ...原创 2019-03-08 11:01:08 · 117 阅读 · 0 评论 -
【sql学习】LeetCode之183. Customers Who Never Order
Suppose that a website contains two tables, theCustomerstable and theOrderstable. Write a SQL query to find all customers who never order anything.Table:Customers.+----+-------+| Id | Name ...原创 2019-03-17 13:17:22 · 231 阅读 · 0 评论 -
【sql学习】LeetCode之196. Delete Duplicate Emails
Write a SQL query todeleteall duplicate email entries in a table namedPerson, keeping only unique emails based on itssmallestId.+----+------------------+| Id | Email |+----+------...原创 2019-03-17 13:27:06 · 251 阅读 · 0 评论 -
【sql学习】LeetCode之175. Combine Two Tables
Table:Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+Pe...原创 2019-03-20 23:25:19 · 235 阅读 · 0 评论 -
LeetCode之56. Merge Intervals
Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] overlaps...原创 2019-03-12 22:02:04 · 221 阅读 · 0 评论 -
LeetCode之86. Partition List
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of t...原创 2019-03-17 22:01:22 · 198 阅读 · 0 评论 -
LeetCode之17. Letter Combinations of a Phone Number
自己的代码:Runtime:0 ms, faster than100.00%ofJavaonline submissions forMinimum Depth of Binary Tree.Memory Usage:40.2 MB, less than5.41%ofJavaonline submissions forMinimum Depth of Binar...原创 2019-03-21 23:08:56 · 136 阅读 · 0 评论 -
【sql学习】LeetCode之182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table namedPerson.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+---------+For e...原创 2019-03-13 21:39:06 · 244 阅读 · 0 评论 -
LeetCode之111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note:A leaf is a node with no childre...原创 2019-03-25 22:14:51 · 320 阅读 · 0 评论 -
LeetCode之26. Remove Duplicates from Sorted Array
Given a sorted arraynums, remove the duplicatesin-placesuch that each element appear onlyonceand return the new length.Do not allocate extra space for another array, you must do this bymodifyi...原创 2019-03-25 22:40:14 · 133 阅读 · 0 评论 -
LeetCode之77. Combinations
Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.Example:Input:n = 4, k = 2Output:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]是一种穷举遍历的思想;...原创 2019-02-26 23:50:29 · 168 阅读 · 0 评论 -
LeetCode之53. Maximum Subarray
Given an integer arraynums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanati...原创 2019-03-02 22:28:59 · 130 阅读 · 0 评论 -
LeetCode之7. Reverse Integer
7. Reverse IntegerEasy17852534FavoriteShareGiven a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:...原创 2018-12-21 20:13:49 · 133 阅读 · 0 评论 -
LeetCode之14. Longest Common Prefix
14. Longest Common PrefixEasy10081089FavoriteShareWrite a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string ""....原创 2018-12-25 11:09:12 · 116 阅读 · 0 评论 -
LeetCode之2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse orderand each of their nodes contain a single digit. Add the two numbers and return it...原创 2019-02-05 19:56:39 · 200 阅读 · 0 评论 -
LeetCode之43. Multiply Strings
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.Example 1:Input: num1 = "2", num2 = "3"Output: "6"Exampl...原创 2019-02-06 12:19:34 · 257 阅读 · 0 评论 -
LeetCode之55. Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if yo...原创 2019-02-22 10:24:06 · 265 阅读 · 0 评论 -
LeetCode之3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Example 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc" , with the length of 3. Example 2:...原创 2019-02-16 22:39:14 · 154 阅读 · 0 评论 -
LeetCode之9. Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121Output: falseExpl...原创 2019-02-17 20:02:15 · 118 阅读 · 0 评论 -
LeetCode之94. Binary Tree Inorder Traversal
Given a binary tree, return theinordertraversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Follow up:Recursive solution is trivial, could y...原创 2019-02-27 19:28:14 · 146 阅读 · 0 评论 -
LeetCode之15. 3Sum
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not cont...原创 2019-02-18 12:38:09 · 131 阅读 · 0 评论 -
LeetCode之79. Word Search
Given 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 horizontally or vertically n...原创 2019-02-23 16:17:44 · 161 阅读 · 0 评论 -
LeetCode之17. Letter Combinations of a Phone Number
17. Letter Combinations of a Phone NumberMedium1823254FavoriteShareGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent....原创 2019-02-18 17:07:42 · 181 阅读 · 0 评论 -
LeetCode之58. Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defin...原创 2019-02-24 23:26:30 · 123 阅读 · 0 评论 -
LeetCode之48. Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have to modify the input 2D matrix d...原创 2019-02-20 10:16:16 · 180 阅读 · 0 评论 -
LeetCode之39. Combination Sum
Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.The same repeat...原创 2019-02-20 14:32:25 · 143 阅读 · 0 评论 -
LeetCode之67. Add Binary
Given two binary strings, return their sum (also a binary string).The input strings are bothnon-emptyand contains only characters1or0.Example 1:Input: a = "11", b = "1"Output: "100"Exam...原创 2019-03-05 21:39:35 · 154 阅读 · 0 评论 -
LeetCode之226. Invert Binary Tree
Invert a binary tree.Example:Input: 4 / \ 2 7 / \ / \1 3 6 9Output: 4 / \ 7 2 / \ / \9 6 3 1自己的代码:(递归)Runtime:0 ms, faster than100.00%o...原创 2019-03-31 21:21:33 · 187 阅读 · 0 评论