![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
My_Vina
不被金钱,他人和过去所打扰.
展开
-
240. 搜索二维矩阵 II
编写一个高效的算法来搜索mxn矩阵 matrix 中的一个目标值 target。该矩阵具有以下特性:每行的元素从左到右升序排列。每列的元素从上到下升序排列。示例:现有矩阵 matrix 如下:[ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19], [3, 6, 9, 16, 22], [10, 13, 14, 17,...原创 2019-11-06 21:24:56 · 99 阅读 · 0 评论 -
221. 最大正方形
在一个由 0 和 1 组成的二维矩阵内,找到只包含 1 的最大正方形,并返回其面积。示例:输入:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0输出: 4class Solution { public int maximalSquare(char[][] matrix) { int m = matrix.length;...原创 2019-11-06 21:19:27 · 86 阅读 · 0 评论 -
132. Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.Example:Input: "aab"Output: 1Explana...原创 2019-04-24 16:18:35 · 84 阅读 · 0 评论 -
133. Clone Graph
Given a reference of a node in a connected undirected graph, return a deep copy (clone) of the graph. Each node in the graph contains a val (int) and a list (List[Node]) of its neighbors. Example...原创 2019-04-24 17:18:46 · 84 阅读 · 0 评论 -
207. Course Schedule
There are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pai...原创 2019-04-29 14:00:43 · 114 阅读 · 0 评论 -
208. Implement Trie (Prefix Tree)
Implement a trie with insert, search, and startsWith methods.Example:Trie trie = new Trie();trie.insert("apple");trie.search("apple"); // returns truetrie.search("app"); // returns fals...原创 2019-04-29 15:07:40 · 91 阅读 · 0 评论 -
210. Course Schedule II
There are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pai...原创 2019-04-29 15:45:18 · 84 阅读 · 0 评论 -
134. Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its...原创 2019-04-24 20:39:45 · 101 阅读 · 0 评论 -
211. Add and Search Word - Data structure design
Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing only letters...原创 2019-04-29 17:16:43 · 108 阅读 · 0 评论 -
212. Word Search II
Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those hori...原创 2019-04-29 21:20:34 · 113 阅读 · 0 评论 -
214. Shortest Palindrome
待续。。。找时间攻克KMP算法。。。原创 2019-04-29 22:41:20 · 136 阅读 · 0 评论 -
215. Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,1,5,6,4] and k = 2Output: 5Exa...原创 2019-04-30 20:59:30 · 92 阅读 · 0 评论 -
289. Game of Life
According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a board with m by ...原创 2019-05-06 19:50:43 · 104 阅读 · 0 评论 -
442. Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra...原创 2019-05-06 20:47:49 · 96 阅读 · 0 评论 -
457. Circular Array Loop
You are given a circular array nums of positive and negative integers. If a number k at an index is positive, then move forward k steps. Conversely, if it's negative (-k), move backward k steps. Sinc...原创 2019-05-09 19:05:26 · 140 阅读 · 0 评论 -
565. Array Nesting
A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below.Suppo...原创 2019-05-27 15:15:52 · 92 阅读 · 0 评论 -
131. Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.Example:Input: "aab"Output:[ ["aa","b"], ["a","a"...原创 2019-04-24 15:18:17 · 79 阅读 · 0 评论 -
201. Bitwise AND of Numbers Range
待续。。。原创 2019-04-29 12:54:22 · 73 阅读 · 0 评论 -
200. Number of Islands
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assum...原创 2019-04-28 20:45:22 · 201 阅读 · 0 评论 -
539. Minimum Time Difference
Given a list of 24-hour clock time points in "Hour:Minutes" format, find the minimum minutes difference between any two time points in the list.Example 1:Input: ["23:59","00:00"]Output: 1Note:The nu...原创 2018-04-10 11:11:08 · 99 阅读 · 0 评论 -
45. Jump Game II
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.Your goal is t...原创 2019-04-22 21:23:35 · 95 阅读 · 0 评论 -
76. Minimum Window Substring
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Example:Input: S = "ADOBECODEBANC", T = "ABC"Output: "BANC"Note:If ...原创 2019-04-23 11:35:17 · 96 阅读 · 0 评论 -
139. Word Break
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.Note:The...原创 2019-04-27 20:16:09 · 91 阅读 · 0 评论 -
140. Word Break II
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible...原创 2019-04-27 21:39:28 · 86 阅读 · 0 评论 -
148. Sort List
Sort a linked list in O(n log n) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: -1->...原创 2019-04-28 13:28:48 · 204 阅读 · 0 评论 -
162. Find Peak Element
A peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.The array may contain multiple peaks...原创 2019-04-28 15:03:06 · 72 阅读 · 0 评论 -
164. Maximum Gap
待续。。。太难了。。。原创 2019-04-28 15:29:32 · 249 阅读 · 0 评论 -
175. Combine Two Tables
Table: Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+Pe...原创 2019-04-28 15:37:38 · 88 阅读 · 0 评论 -
176. Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For exampl...原创 2019-04-28 15:56:05 · 104 阅读 · 0 评论 -
177. Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For example, ...原创 2019-04-28 16:13:39 · 89 阅读 · 0 评论 -
178. Rank Scores
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive integer value....原创 2019-04-28 16:24:04 · 104 阅读 · 0 评论 -
180. Consecutive Numbers
Write a SQL query to find all numbers that appear at least three times consecutively.+----+-----+| Id | Num |+----+-----+| 1 | 1 || 2 | 1 || 3 | 1 || 4 | 2 || 5 | 1 || 6 | ...原创 2019-04-28 16:36:19 · 182 阅读 · 0 评论 -
126. Word Ladder II
Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that:Only one letter can be changed at a timeEac...原创 2019-04-24 11:26:24 · 101 阅读 · 0 评论 -
188. Best Time to Buy and Sell Stock IV
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may not en...原创 2019-04-28 20:10:04 · 83 阅读 · 0 评论 -
129. Sum Root to Leaf Numbers
这是一道关于二叉树树的题目,题目的本质是进行遍历各节点。代码如下:class Solution(object): def Get_Sum(self, root, n): if not root: return 0 if not root.left and not root.right: return n原创 2018-02-02 21:31:05 · 83 阅读 · 0 评论