
Leetcode
CCCCCCCYYY_
不会翻身的咸鱼一条
展开
-
【LeetCode】1641. Count Sorted Vowel Strings(动态规划)
【LeetCode】1641. Count Sorted Vowel Strings(动态规划)Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.A string s is lexicographically sorted if for all valid i, s[i] is t原创 2021-06-30 18:19:13 · 323 阅读 · 0 评论 -
【LeetCode】739.Even Odd Tree (BFS宽度优先搜索)
【LeetCode】739.Even Odd Tree (BFS宽度优先搜索)A binary tree is named Even-Odd if it meets the following conditions:The root of the binary tree is at level index 0, its children are at level index 1, their children are at level index 2, etc.For every even-index原创 2021-02-21 18:19:26 · 228 阅读 · 0 评论 -
【LeetCode】739. Daily Temperatures 栈的使用
【LeetCode】739. Daily Temperatures 栈的使用Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible原创 2020-12-23 17:37:08 · 130 阅读 · 0 评论 -
【LeetCode】动态规划:第62题. Unique Paths
62. Unique PathsA robot is located at the top-left corner of a m x n grid (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 bottom-right corner of the grid (marked ‘F原创 2020-11-16 15:23:46 · 134 阅读 · 0 评论 -
【LeetCode】424. Longest Repeating Character Replacement滑动窗口算法
【LeetCode】424. Longest Repeating Character Replacement滑动窗口Given a string s that consists of only uppercase English letters, you can perform at most k operations on that string.In one operation, you can choose any character of the string and change it to原创 2020-09-16 15:15:54 · 146 阅读 · 0 评论 -
【LeetCode】662. Maximum Width of Binary Tree二叉树的最大宽度
662. Maximum Width of Binary Tree二叉树的最大宽度Given a binary tree, write a function to get the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels.The width of one level is defined as the length between the end-n原创 2020-08-22 22:35:44 · 140 阅读 · 0 评论 -
Leetcode学习笔记:#1 Two Sum
Leetcode学习笔记:#1 Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and yo...原创 2019-05-05 15:33:27 · 151 阅读 · 0 评论 -
Leetcode学习笔记:#2 Add Two Numbers
Leetcode学习笔记:#2 Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. ...原创 2019-05-05 16:24:44 · 125 阅读 · 0 评论 -
Leetcode学习笔记:#3 Longest Substring Without Repeating Characters
Leetcode学习笔记:#3 Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.实现:public int lengthOfLongestSubstring(String s){...原创 2019-05-05 17:03:22 · 100 阅读 · 0 评论 -
Leetcode学习笔记:#26. Remove Duplicates from Sorted Array
Leetcode学习笔记:#26. Remove Duplicates from Sorted ArrayGiven a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra...原创 2019-05-08 13:50:25 · 155 阅读 · 0 评论 -
Leetcode学习笔记:#27. Remove Element
Leetcode学习笔记:#27. Remove ElementGiven an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do ...原创 2019-05-08 13:54:16 · 101 阅读 · 0 评论 -
Leetcode学习笔记:#28. Implement strStr()
Leetcode学习笔记:#28. Implement strStr()Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.实现:public int strStr(String haystack,...原创 2019-05-08 14:12:04 · 123 阅读 · 0 评论 -
Leetcode学习笔记:#36. Valid Sudoku
Leetcode学习笔记:#36. Valid SudokuDetermine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repet...原创 2019-05-08 14:32:06 · 120 阅读 · 0 评论 -
Leetcode学习笔记:#35. Search Insert Position
Leetcode学习笔记:#35. Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You ...原创 2019-05-08 14:38:39 · 128 阅读 · 0 评论 -
Leetcode学习笔记:#1038. Binary Search Tree to Greater Sum Tree
Leetcode学习笔记:#1038. Binary Search Tree to Greater Sum TreeGiven the root of a binary search tree with distinct values, modify it so that every node has a new value equal to the sum of the values of t...原创 2019-05-08 17:01:03 · 201 阅读 · 0 评论 -
Leetcode学习笔记:#807. Max Increase to Keep City Skyline
Leetcode学习笔记:#807. Max Increase to Keep City SkylineIn a 2 dimensional array grid, each value grid[i][j] represents the height of a building located there. We are allowed to increase the height of an...原创 2019-05-08 17:15:04 · 122 阅读 · 0 评论 -
Leetcode学习笔记:#654. Maximum Binary Tree
Leetcode学习笔记:#654. Maximum Binary TreeGiven an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array.The left subt...原创 2019-05-08 17:24:11 · 137 阅读 · 0 评论 -
Leetcode学习笔记:#701. Insert into a Binary Search Tree
Leetcode学习笔记:#701. Insert into a Binary Search TreeGiven the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of t...原创 2019-05-08 17:41:39 · 87 阅读 · 0 评论 -
Leetcode学习笔记:#1008. Construct Binary Search Tree from Preorder Traversal
Leetcode学习笔记:#1008. Construct Binary Search Tree from Preorder TraversalReturn the root node of a binary search tree that matches the given preorder traversal.(Recall that a binary search tree is a ...原创 2019-05-09 14:45:01 · 181 阅读 · 0 评论 -
Leetcode学习笔记:#617. Merge Two Binary Trees
Leetcode学习笔记:#617. Merge Two Binary TreesGiven two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You ...原创 2019-05-13 17:56:11 · 111 阅读 · 0 评论 -
Leetcode学习笔记:#977. Squares of a Sorted Array
Leetcode学习笔记:#977. Squares of a Sorted ArrayGiven 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.实现:public...原创 2019-05-13 18:00:28 · 93 阅读 · 0 评论 -
Leetcode学习笔记:#852. Peak Index in a Mountain Array
Leetcode学习笔记:#852. Peak Index in a Mountain ArrayLet’s call an array A a mountain if the following properties hold:A.length >= 3There exists some 0 < i < A.length - 1 such that A[0] < A...原创 2019-05-13 18:10:38 · 113 阅读 · 0 评论 -
Leetcode学习笔记:#728. Self Dividing Numbers
Leetcode学习笔记:#728. Self Dividing NumbersA self-dividing number is a number that is divisible by every digit it contains.For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0,...原创 2019-05-13 18:33:46 · 157 阅读 · 0 评论 -
Leetcode学习笔记:#933. Number of Recent Calls
Leetcode学习笔记:933. Number of Recent CallsWrite a class RecentCounter to count recent requests.It has only one method: ping(int t), where t represents some time in milliseconds.Return the number of p...原创 2019-05-13 18:36:07 · 155 阅读 · 0 评论 -
Leetcode学习笔记:#627. Swap Salary
Leetcode学习笔记:#627. Swap SalaryGiven a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice versa) with a single u...原创 2019-05-13 18:40:22 · 80 阅读 · 0 评论 -
Leetcode学习笔记:#771 Jewels and Stones
Leetcode学习笔记:#771 Jewels and StonesYou’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. ...原创 2019-05-06 17:01:46 · 92 阅读 · 0 评论 -
Leetcode学习笔记:#938. Range Sum of BST
Leetcode学习笔记:#938. Range Sum of BSTGiven the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive).The binary search tree is guaranteed to h...原创 2019-05-06 17:16:23 · 121 阅读 · 0 评论 -
Leetcode学习笔记:#700. Search in a Binary Search Tree
Leetcode学习笔记:#700. Search in a Binary Search TreeGiven the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node’s value equals the given value. Retu...原创 2019-05-14 15:25:39 · 108 阅读 · 0 评论 -
Leetcode学习笔记:#922. Sort Array By Parity II
Leetcode学习笔记:#922. Sort Array By Parity IIGiven an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even.Sort the array so that whenever A[i] is odd,...原创 2019-05-14 15:35:20 · 117 阅读 · 0 评论 -
Leetcode学习笔记:#965. Univalued Binary Tree
Leetcode学习笔记:#965. Univalued Binary TreeA binary tree is univalued if every node in the tree has the same value.Return true if and only if the given tree is univalued.实现:public boolean isUnivalTre...原创 2019-05-14 15:37:41 · 119 阅读 · 0 评论 -
Leetcode学习笔记:#509. Fibonacci Number
Leetcode学习笔记:#509. Fibonacci NumberThe Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting fr...原创 2019-05-14 15:41:42 · 122 阅读 · 0 评论 -
Leetcode学习笔记:#559. Maximum Depth of N-ary Tree
Leetcode学习笔记:#559. Maximum Depth of N-ary TreeGiven a n-ary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf ...原创 2019-05-14 15:47:37 · 171 阅读 · 0 评论 -
Leetcode学习笔记:#950. Reveal Cards In Increasing Order
Leetcode学习笔记:#950. Reveal Cards In Increasing OrderIn a deck of cards, every card has a unique integer. You can order the deck in any order you want.Initially, all the cards start face down (unreve...原创 2019-05-09 17:37:15 · 168 阅读 · 0 评论 -
Leetcode学习笔记:#897. Increasing Order Search Tree
Leetcode学习笔记:#897. Increasing Order Search TreeGiven a tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and onl...原创 2019-05-14 15:57:23 · 131 阅读 · 0 评论 -
Leetcode学习笔记:#867. Transpose Matrix
Leetcode学习笔记:#867. Transpose MatrixGiven a matrix A, return the transpose of A.The transpose of a matrix is the matrix flipped over it’s main diagonal, switching the row and column indices of the ma...原创 2019-05-14 16:02:54 · 106 阅读 · 0 评论 -
Leetcode学习笔记:#876. Middle of the Linked List
Leetcode学习笔记:#876. Middle of the Linked ListGiven a non-empty, singly linked list with head node head, return a middle node of linked list.If there are two middle nodes, return the second middle nod...原创 2019-05-14 16:06:41 · 146 阅读 · 0 评论 -
Leetcode学习笔记:#890. Find and Replace Pattern
Leetcode学习笔记:#890. Find and Replace PatternYou have a list of words and a pattern, and you want to know which words in words matches the pattern.A word matches the pattern if there exists a permutat...原创 2019-05-09 17:58:44 · 165 阅读 · 0 评论 -
Leetcode学习笔记:#814. Binary Tree Pruning
Leetcode学习笔记:#814. Binary Tree PruningWe are given the head node root of a binary tree, where additionally every node’s value is either a 0 or a 1.Return the same tree where every subtree (of the gi...原创 2019-05-09 18:33:41 · 109 阅读 · 0 评论 -
Leetcode学习笔记:#350. Intersection of Two Arrays II
Leetcode学习笔记:#350. Intersection of Two Arrays IIGiven two arrays, write a function to compute their intersection.实现:public int[] intersect(int[] nums1, int[] nums2) { HashMap<Integer, In...原创 2019-05-19 19:50:32 · 159 阅读 · 0 评论 -
Leetcode学习笔记:#572. Subtree of Another Tree
Leetcode学习笔记:#572. Subtree of Another TreeGiven two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree c...原创 2019-05-19 20:36:25 · 126 阅读 · 0 评论