![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Solved
weixin_39145266
这个作者很懒,什么都没留下…
展开
-
742 Closest Leaf in a Binary Tree
1 题目Given a binary treewhere every node has a unique value, and a target keyk, find the value of the nearest leaf node to targetkin the tree.Here,nearestto a leaf means the least number of e...原创 2020-01-06 10:44:09 · 132 阅读 · 0 评论 -
314 Binary Tree Vertical Order Traversal
1 题目Given a binary tree, return thevertical ordertraversal of its nodes' values. (ie, from top to bottom, column by column).If two nodes are in the same row and column, the order should be from...原创 2020-01-06 06:52:23 · 117 阅读 · 0 评论 -
1155 Number of Dice Rolls With Target Sum
1 题目You haveddice, and each die hasffaces numbered1, 2, ..., f.Return the number of possible ways (out offdtotal ways)modulo10^9 + 7to roll the dice so the sum of the face up numbers equ...原创 2019-12-18 10:47:23 · 154 阅读 · 0 评论 -
843 Guess the Word
1 题目This problem is aninteractive problemnew to the LeetCode platform.We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen assecret.You m...原创 2019-12-15 06:09:44 · 107 阅读 · 0 评论 -
348 Design Tic-Tac-Toe
1 题目Design a Tic-tac-toe game that is played between two players on anxngrid.You may assume the following rules:A move is guaranteed to be valid and is placed on an empty block. Once a winn...原创 2019-12-05 10:55:19 · 134 阅读 · 0 评论 -
1099 Two Sum Less Than K
1 题目Given an arrayAof integers andintegerK, return the maximumSsuch that there existsi < jwithA[i] + A[j] = SandS < K. If noi, jexist satisfying this equation, return -1.Example...原创 2019-12-05 08:15:50 · 114 阅读 · 0 评论 -
146 LRU Cache
1 题目Design and implement a data structure forLeast Recently Used (LRU) cache. It should support the following operations:getandput.get(key)- Get the value (will always be positive) of the key...原创 2019-12-03 09:45:09 · 78 阅读 · 0 评论 -
957 Prison Cells After N Days
1 题目There are 8 prison cells in a row, and each cell is either occupied or vacant.Each day, whether the cell is occupied or vacant changes according to the following rules:If a cell has two adja...原创 2019-12-01 07:40:28 · 94 阅读 · 0 评论 -
1167 Minimum Cost to Connect Sticks
1 题目You have somestickswithpositive integer lengths.You can connect any two sticks of lengthsXandYinto one stickby paying a cost ofX + Y. You perform this action until there is one stick...原创 2019-12-01 05:31:19 · 166 阅读 · 0 评论 -
1143 Longest Common Subsequence
1 题目Given two stringstext1andtext2, return the length of their longest common subsequence.Asubsequenceof a string is a new string generated from the original string with some characters(can b...原创 2019-11-26 13:54:20 · 93 阅读 · 0 评论 -
572 Subtree of Another Tree
1 题目Given two non-empty binary treessandt, check whether treethas exactly the same structure and node values with a subtree ofs. A subtree ofsis a tree consists of a node insand all of thi...原创 2019-11-24 10:17:54 · 61 阅读 · 0 评论 -
937 Reorder Data in Log Files
1 题目You have an array oflogs. Each log is a space delimited string of words.For each log, the first word in each log is an alphanumericidentifier. Then, either:Each word after the identifier...原创 2019-11-21 10:43:46 · 199 阅读 · 0 评论 -
409 Longest Palindrome
1 题目Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example"Aa"is not...原创 2019-11-21 03:27:44 · 53 阅读 · 0 评论 -
1153 String Transforms Into Another String
1 题目Given two stringsstr1andstr2of the same length, determine whether you can transformstr1intostr2by doingzero or moreconversions.In one conversion you can convertalloccurrences of on...原创 2019-10-31 14:17:52 · 139 阅读 · 0 评论 -
59 Spiral Matrix II
1 题目Given a positive integern, generate a square matrix filled with elements from 1 ton2in spiral order.Example:Input: 3Output:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ]]2 尝试解class S...原创 2019-03-29 09:18:46 · 49 阅读 · 0 评论 -
48 Rotate Image
1 题目You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the imagein-place, which means you have to modify the input 2D ma...原创 2019-03-29 09:15:51 · 50 阅读 · 0 评论 -
61 Rotate List
1 题目Given a linkedlist, rotate the list to the right bykplaces, wherekis non-negative.2 尝试解class Solution {public: ListNode* rotateRight(ListNode* head, int k) { if(head == NU...原创 2019-03-29 09:16:15 · 42 阅读 · 0 评论 -
5 Longest Palindromic Substring
1 题目Given a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer....原创 2019-03-29 09:16:34 · 56 阅读 · 0 评论 -
36 Valid Sudoku
1 题目Determine if a9x9 Sudoku boardis valid.Only the filled cells need to be validatedaccording to the following rules:Each rowmust contain thedigits1-9without repetition. Each column must...原创 2019-03-29 09:15:59 · 61 阅读 · 0 评论 -
8 String to Integer (atoi)
1 题目Implementatoiwhichconverts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting fr...原创 2019-03-29 09:16:08 · 59 阅读 · 0 评论 -
12 Integer to Roman
1 题目Roman numerals are represented by seven different symbols:I,V,X,L,C,DandM.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2019-03-29 09:16:25 · 44 阅读 · 0 评论 -
92 Reverse Linked List II
1 题目Reverse a linked list from positionmton. Do it in one-pass.Note:1 ≤m≤n≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2-...原创 2019-03-30 11:28:00 · 42 阅读 · 0 评论 -
62 Unique Paths
1 题目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 ...原创 2019-03-29 09:19:17 · 67 阅读 · 0 评论 -
63 Unique Paths II
1 题目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 ...原创 2019-03-29 09:16:42 · 62 阅读 · 0 评论 -
55 Jump Game
1 题目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...原创 2019-03-29 09:19:33 · 50 阅读 · 0 评论 -
49 Group Anagrams
1 题目Given an array of strings, group anagrams together.2 尝试解class Solution {public: vector<vector<string>> groupAnagrams(vector<string>& strs) { map<string...原创 2019-03-29 09:19:12 · 60 阅读 · 0 评论 -
94 Binary Tree Inorder Traversal
1 题目Given a binary tree, return theinordertraversal of its nodes' values.2 尝试解class Solution {public: vector<int> inorderTraversal(TreeNode* root) { vector<int> resul...原创 2019-03-29 09:19:02 · 55 阅读 · 0 评论 -
75 Sort Colors
1 题目Given an array withnobjects colored red, white or blue, sort themin-placeso that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use ...原创 2019-03-29 09:17:19 · 80 阅读 · 0 评论 -
54 Spiral Matrix
1 题目Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.2 尝试解class Solution {public: vector<int> spiralOrder(vector<vector<i...原创 2019-03-29 09:18:50 · 63 阅读 · 0 评论 -
6 ZigZag Conversion
1 题目The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L...原创 2019-03-29 09:17:34 · 58 阅读 · 0 评论 -
80 Remove Duplicates from Sorted Array II
1 题目Given a sorted arraynums, remove the duplicatesin-placesuch that duplicates appeared at mosttwiceand return the new length.Do not allocate extra space for another array, you must do this ...原创 2019-03-29 09:17:26 · 65 阅读 · 0 评论 -
274 H-Index
1 题目Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to thedefinition of h-index on Wikipedia:...原创 2019-04-04 23:50:29 · 120 阅读 · 0 评论 -
299 Bulls and Cows
1 题目You are playing the followingBulls and Cowsgame with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hi...原创 2019-04-05 08:13:36 · 525 阅读 · 0 评论 -
64 Minimum Path Sum
1 题目Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move either down or righ...原创 2019-03-29 09:18:18 · 52 阅读 · 0 评论 -
151 Reverse Words in a String
1 题目Given an input string, reverse the string word by word.Example 1:Input: "the sky is blue"Output:"blue is sky the"Example 2:Input: " hello world! "Output:"world! hello"Explan...原创 2019-04-05 14:56:46 · 62 阅读 · 0 评论 -
114 Flatten Binary Tree to Linked List
1 题目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-04-05 15:42:01 · 76 阅读 · 0 评论 -
46 Permutations
1 题目Given a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]2 尝试解class ...原创 2019-04-05 16:18:39 · 67 阅读 · 0 评论 -
74 Search a 2D Matrix
1 题目Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first integer of ea...原创 2019-03-29 09:18:10 · 58 阅读 · 0 评论 -
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 ...原创 2019-04-10 15:28:30 · 69 阅读 · 0 评论 -
78 Subsets
1 题目Given a set ofdistinctintegers,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[ [3]...原创 2019-03-29 09:17:01 · 71 阅读 · 0 评论