随笔分类 -  LeetCode

摘要:A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0), followed by some number of '1's (also possibly 0. 阅读全文
posted @ 2020-11-19 11:45 Sheanne 阅读(75) 评论(0) 推荐(0)
摘要:You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow an 阅读全文
posted @ 2020-11-19 06:42 Sheanne 阅读(91) 评论(0) 推荐(0)
摘要:For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, ..., N, such that: For every i < j, there is no k with i < k < 阅读全文
posted @ 2020-11-19 06:12 Sheanne 阅读(96) 评论(0) 推荐(0)
摘要:Given an array nums of 0s and 1s and an integer k, return True if all 1's are at least k places away from each other, otherwise return False. Example 阅读全文
posted @ 2020-11-19 00:23 Sheanne 阅读(92) 评论(0) 推荐(0)
摘要: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 sequ 阅读全文
posted @ 2020-11-17 11:02 Sheanne 阅读(78) 评论(0) 推荐(0)
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Input: 3 Output: 5 Explanation: Given n = 3, the 阅读全文
posted @ 2020-11-17 10:51 Sheanne 阅读(102) 评论(0) 推荐(0)
摘要:Given a string s, return the maximum number of unique substrings that the given string can be split into. You can split string s into any list of non- 阅读全文
posted @ 2020-11-17 10:31 Sheanne 阅读(153) 评论(0) 推荐(0)
摘要:Given a binary tree, return the sum of values of its deepest leaves. Example 1: Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8] Output: 15 Co 阅读全文
posted @ 2020-11-16 06:43 Sheanne 阅读(96) 评论(0) 推荐(0)
摘要:Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the pers 阅读全文
posted @ 2020-11-16 06:30 Sheanne 阅读(93) 评论(0) 推荐(0)
摘要:You are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct. Your goal is to form 阅读全文
posted @ 2020-11-16 05:19 Sheanne 阅读(258) 评论(0) 推荐(0)
摘要:Given the root node of a binary search tree, return the sum of values of all nodes with a value in the range [low, high]. Example 1: Input: root = [10 阅读全文
posted @ 2020-11-16 04:27 Sheanne 阅读(78) 评论(0) 推荐(0)
摘要:112 Path Sum 和113 Path Sum2 关注的是从root到leaf的情况,437 Path Sum3 关注的是任一点 downwards到某一个点的情况。 三题感觉都是比较典型的dfs题。 112 # Definition for a binary tree node. # cla 阅读全文
posted @ 2020-11-15 10:27 Sheanne 阅读(82) 评论(0) 推荐(0)
摘要:Given an n-ary tree, return the level order traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversa 阅读全文
posted @ 2020-11-09 10:14 Sheanne 阅读(59) 评论(0) 推荐(0)
摘要:Given a string s, return the maximum number of ocurrences of any substring under the following rules: The number of unique characters in the substring 阅读全文
posted @ 2020-11-09 09:58 Sheanne 阅读(147) 评论(0) 推荐(0)
摘要:Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true方法:先把linked 阅读全文
posted @ 2020-11-09 09:23 Sheanne 阅读(71) 评论(0) 推荐(0)
摘要:Given the root of a binary tree, return the sum of every tree node's tilt. The tilt of a tree node is the absolute difference between the sum of all l 阅读全文
posted @ 2020-11-09 01:46 Sheanne 阅读(130) 评论(0) 推荐(0)
摘要:Given an array of integers arr. Return the number of sub-arrays with odd sum. As the answer may grow large, the answer must be computed modulo 10^9 + 阅读全文
posted @ 2020-11-08 07:38 Sheanne 阅读(103) 评论(0) 推荐(0)
摘要:Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of sto 阅读全文
posted @ 2020-11-08 07:03 Sheanne 阅读(84) 评论(0) 推荐(0)
摘要:You have n candies, the ith candy is of type candies[i]. You want to distribute the candies equally between a sister and a brother so that each of the 阅读全文
posted @ 2020-11-08 04:50 Sheanne 阅读(64) 评论(0) 推荐(0)
摘要:You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contai 阅读全文
posted @ 2020-11-08 04:32 Sheanne 阅读(71) 评论(0) 推荐(0)