![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode每日一题202010
Bryan要加油
这个作者很懒,什么都没留下…
展开
-
381. Insert Delete GetRandom O(1) - Duplicates allowed(Leetcode每日一题-2020.10.31)
ProblemDesign a data structure that supports all following operations in average O(1) time.Note: Duplicate elements are allowed.insert(val): Inserts an item val to the collection.remove(val): Removes an item val from the collection if present.getRand原创 2020-11-01 22:09:21 · 185 阅读 · 0 评论 -
463. Island Perimeter(Leetcode每日一题-2020.10.30)
ProblemYou are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water.Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is ex原创 2020-11-01 22:06:57 · 210 阅读 · 0 评论 -
129. Sum Root to Leaf Numbers(Leetcode每日一题-2020.10.29)
ProblemGiven a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of all root-to-leaf numbers.Note: A leaf is原创 2020-10-29 21:37:27 · 111 阅读 · 0 评论 -
1207. Unique Number of Occurrences(Leetcode每日一题-2020.10.28)
ProblemGiven an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique.Constraints:1 <= arr.length <= 1000-1000 <= arr[i] <= 1000Example1Input: arr = [1,2原创 2020-10-28 21:14:24 · 167 阅读 · 0 评论 -
144. Binary Tree Preorder Traversal(Leetcode每日一题-2020.10.27)
ProblemGiven the root of a binary tree, return the preorder traversal of its nodes’ values.Example1Input: root = [1,null,2,3]Output: [1,2,3]Example2Input: root = []Output: []Example3Input: root = [1]Output: [1]Example4Input: root = [1,原创 2020-10-27 21:27:21 · 155 阅读 · 0 评论 -
1024. Video Stitching(Leetcode每日一题-2020.10.24)--抄答案
ProblemYou are given a series of video clips from a sporting event that lasted T seconds. These video clips can be overlapping with each other and have varied lengths.Each video clip clips[i] is an interval: it starts at time clips[i][0] and ends at tim原创 2020-10-24 22:08:09 · 318 阅读 · 0 评论 -
234. Palindrome Linked List(Leetcode每日一题-2020.10.23)
ProblemGiven a singly linked list, determine if it is a palindrome.Example1Input: 1->2Output: falseExample2Input: 1->2->2->1Output: trueSolution/** * Definition for singly-linked list. * struct ListNode { * int val; * L原创 2020-10-23 22:04:29 · 253 阅读 · 0 评论 -
763. Partition Labels(Leetcode每日一题-2020.10.22)
ProblemA string S of lowercase English letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts.Note:S will hav原创 2020-10-23 22:03:09 · 341 阅读 · 0 评论 -
925. Long Pressed Name(Leetcode每日一题-2020.10.21)
ProblemYour friend is typing his name into a keyboard. Sometimes, when typing a character c, the key might get long pressed, and the character will be typed 1 or more times.You examine the typed characters of the keyboard. Return True if it is possible原创 2020-10-21 19:32:49 · 340 阅读 · 0 评论 -
143. Reorder List(Leetcode每日一题-2020.10.20)
ProblemGiven a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You may not modify the values in the list’s nodes, only nodes itself may be changed.Example1Given 1->2->3->4, reorder it to 1->4->2->3.Exam原创 2020-10-20 21:18:10 · 283 阅读 · 0 评论 -
844. Backspace String Compare(Leetcode每日一题-2020.10.19)
ProblemGiven two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.Note that after backspacing an empty text, the text will continue empty.Note:1 <= S.length <= 2001 <= T.len原创 2020-10-20 21:16:51 · 376 阅读 · 0 评论 -
19. Remove Nth Node From End of List(Leetcode每日一题-2020.10.18)
ProblemGiven the head of a linked list, remove the nth node from the end of the list and return its head.Constraints:The number of nodes in the list is sz.1 <= sz <= 300 <= Node.val <= 1001 <= n <= sz来源:力扣(LeetCode)链接:https://le原创 2020-10-18 21:41:13 · 272 阅读 · 0 评论 -
52. N-Queens II(Leetcode每日一题-2020.10.17)
ProblemThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return the number of distinct solutions to the n-queens puzzle.ExampleInput: 4Output: 2Explanation: The原创 2020-10-17 21:28:54 · 517 阅读 · 0 评论 -
977. Squares of a Sorted Array(Leetcode每日一题-2020.10.16)
ProblemGiven an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.Note:1 <= A.length <= 10000-10000 <= A[i] <= 10000A is sorted in non-decreasing order.原创 2020-10-17 21:27:21 · 310 阅读 · 0 评论 -
116. Populating Next Right Pointers in Each Node(Leetcode每日一题-2020.10.15)
ProblemYou are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node {int val;Node *left;Node *right;Node *next;}Populate each next pointer原创 2020-10-15 21:49:00 · 445 阅读 · 0 评论 -
1002. Find Common Characters(Leetcode每日一题-2020.10.14)--抄答案
ProblemGiven an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates). For example, if a character occurs 3 times in all strings but not 4 times, you need t原创 2020-10-14 21:25:55 · 197 阅读 · 0 评论 -
24. Swap Nodes in Pairs(Leetcode每日一题-2020.10.13)
ProblemGiven a linked list, swap every two adjacent nodes and return its head.You may not modify the values in the list’s nodes. Only nodes itself may be changed.Constraints:The number of nodes in the list is in the range [0, 100].0 <= Node.val &l原创 2020-10-13 21:03:32 · 329 阅读 · 0 评论 -
530. Minimum Absolute Difference in BST&783. Minimum Distance... (Leetcode每日一题-2020.10.12)
ProblemGiven a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.Note:There are at least two nodes in this BST.ExampleSolution/** * Definition for a binary tree node. * struct TreeNode原创 2020-10-12 19:57:38 · 168 阅读 · 0 评论 -
416. Partition Equal Subset Sum(Leetcode每日一题-2020.10.11)
ProblemGiven a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Each of the array element will not exceed 100.The array size will not e原创 2020-09-21 20:59:15 · 397 阅读 · 0 评论 -
142. Linked List Cycle II(Leetcode每日一题-2020.10.10)
ProblemGiven a linked list, return the node where the cycle begins. If there is no cycle, return null.There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, po原创 2020-10-10 21:01:50 · 255 阅读 · 0 评论 -
141. Linked List Cycle(Leetcode每日一题-2020.10.09)
ProblemGiven head, the head of a linked list, determine if the linked list has a cycle in it.There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used原创 2020-10-09 21:59:17 · 700 阅读 · 0 评论 -
344. Reverse String(Leetcode每日一题-2020.10.08)
ProblemWrite a function that reverses a string. The input string is given as an array of characters char[].Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.You may assume all th原创 2020-10-08 20:55:44 · 195 阅读 · 0 评论 -
75. Sort Colors(Leetcode每日一题-2020.10.07)
ProblemGiven an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.Here, we will use the integers 0, 1, and 2 to represent the color原创 2020-10-07 21:59:11 · 1305 阅读 · 0 评论 -
834. Sum of Distances in Tree(Leetcode每日一题-2020.10.06)--抄答案
ProblemAn undirected, connected tree with N nodes labelled 0…N-1 and N-1 edges are given.The ith edge connects nodes edges[i][0] and edges[i][1] together.Return a list ans, where ans[i] is the sum of the distances between node i and all other nodes.Not原创 2020-10-07 21:55:52 · 376 阅读 · 0 评论 -
18. 4Sum(Leetcode每日一题-2020.10.05)
ProblemGiven an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Notice that the solution set must not conta原创 2020-10-07 21:54:27 · 707 阅读 · 0 评论 -
2. Add Two Numbers(Leetcode每日一题-2020.10.04)
ProblemYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.You may assume the tw原创 2020-10-07 21:51:54 · 397 阅读 · 0 评论 -
1. Two Sum(Leetcode每日一题-2020.10.03)
ProblemGiven an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution, and you may not use the same element twice.You can return the原创 2020-10-07 21:48:58 · 212 阅读 · 0 评论 -
771. Jewels and Stones(Leetcode每日一题-2020.10.02)
ProblemYou’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.The letters in J a原创 2020-10-07 21:45:37 · 532 阅读 · 0 评论 -
LCP 19. 秋叶收藏集(Leetcode每日一题-2020.10.01)--抄答案
Problem小扣出去秋游,途中收集了一些红叶和黄叶,他利用这些叶子初步整理了一份秋叶收藏集 leaves, 字符串 leaves 仅包含小写字符 r 和 y, 其中字符 r 表示一片红叶,字符 y 表示一片黄叶。出于美观整齐的考虑,小扣想要将收藏集中树叶的排列调整成「红、黄、红」三部分。每部分树叶数量可以不相等,但均需大于等于 1。每次调整操作,小扣可以将一片红叶替换成黄叶或者将一片黄叶替换成红叶。请问小扣最少需要多少次调整操作才能将秋叶收藏集调整完毕。Contraints:3 <= le转载 2020-10-07 21:41:30 · 410 阅读 · 0 评论