03 2020 档案
摘要:Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the
阅读全文
摘要:Given an array of integers nums, sort the array in ascending order and return it. You must solve the problem without using any built-in functions in O
阅读全文
摘要:Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in b
阅读全文
摘要:Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the resu
阅读全文
摘要:Given a list of words, we may encode it by writing a reference string S and a list of indexes A. For example, if the list of words is ["time", "me", "
阅读全文
摘要:You are given an 8 x 8 matrix representing a chessboard. There is exactly one white rook represented by 'R', some number of white bishops 'B', and som
阅读全文
摘要:Given two binary strings a and b, return their sum as a binary string. Example 1: Input: a = "11", b = "1" Output: "100" Example 2: Input: a = "1010",
阅读全文
摘要:Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The length of both num1 and num2 is < 5100
阅读全文
摘要:Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You mus
阅读全文
摘要:弱智题。就是在做if语句的判断,最后输出的是一个数组。 3的倍数输出Fizz,5的倍数输出Buzz,同时为3和5的倍数输出FizzBuzz。例子, Example: n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8",
阅读全文
摘要:Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive. Example 1: I
阅读全文
摘要:You are given two strings s and t. String t is generated by random shuffling string s and then add one more letter at a random position. Return the le
阅读全文
摘要:这两题我放在一起说是因为思路一模一样,没什么值得研究的。思路都是用对数的换底公式去判断。 Reference, https://blog.csdn.net/qy20115549/article/details/52849280 JavaScript实现 1 /** 2 * @param {numbe
阅读全文
摘要:Given an integer n, return true if it is a power of two. Otherwise, return false. An integer n is a power of two, if there exists an integer x such th
阅读全文
摘要:Given an input string, reverse the string word by word. Example: Input: ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"] Output: ["b
阅读全文
摘要: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!
阅读全文
摘要:Given a list of non-negative integers nums, arrange them such that they form the largest number. Note: The result may be very large, so you need to re
阅读全文
摘要:Given 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 middl
阅读全文
摘要:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any
阅读全文
摘要:You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to th
阅读全文
摘要:There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-rig
阅读全文
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.
阅读全文
摘要:You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number. For example, the r
阅读全文
摘要:Given the root of a complete binary tree, return the number of the nodes in the tree. According to Wikipedia, every level, except possibly the last, i
阅读全文
摘要:Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target. Note: Given target value is a floati
阅读全文
摘要:Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target. Note: Given target value is a floati
阅读全文
摘要:Given a binary search tree and a node in it, find the in-order successor of that node in the BST. The successor of a node p is the node with the small
阅读全文
摘要:Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node.
阅读全文
摘要:Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree. Exampl
阅读全文
摘要:Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The produc
阅读全文
摘要:Convert a non-negative integer num to its English words representation. Example 1: Input: num = 123 Output: "One Hundred Twenty Three" Example 2: Inpu
阅读全文
摘要:Given a string, determine if a permutation of the string could form a palindrome. Example 1: Input: "code" Output: false Example 2: Input: "aab" Outpu
阅读全文
摘要:Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. L
阅读全文
摘要:A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear i
阅读全文
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l
阅读全文
摘要:本博客不定期更新 LeetCode 题目总结,所有题目使用 Java 实现,前 400 题的部分题目也提供 JavaScript 代码。但是我想现如今你完全可以用任何 AI 工具把 Java 代码翻译成 JavaScript 或任何其他语言以达到学习的目的。我不追求一行 AC 但是我追求一题多解,比
阅读全文
摘要:Given the root of a binary tree, return the length of the longest path, where each node in the path has the same value. This path may or may not pass
阅读全文
摘要:Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwee
阅读全文
摘要:Given the root of a binary tree, flatten the tree into a "linked list": The "linked list" should use the same TreeNode class where the right child poi
阅读全文
摘要:Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If n
阅读全文
摘要:Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in
阅读全文
摘要:The next greater element of some element x in an array is the first greater element that is to the right of x in the same array. You are given two dis
阅读全文
摘要:Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have t
阅读全文
摘要:You are given the head of a linked list with n nodes. For each node in the list, find the value of the next greater node. That is, for each node, find
阅读全文
摘要: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
阅读全文
摘要:In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domino is a tile with two numbers from 1 to 6 - one on
阅读全文
摘要:Given an array of strings words and an integer k, return the k most frequent strings. Return the answer sorted by the frequency from highest to lowest
阅读全文
摘要:We have a list of points on the plane. Find the K closest points to the origin (0, 0). (Here, the distance between two points on a plane is the Euclid
阅读全文
摘要:Given the root of a binary tree, return the number of uni-value subtrees. A uni-value subtree means all nodes of the subtree have the same value. Exam
阅读全文
摘要:Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and
阅读全文
摘要:There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i
阅读全文
摘要:There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i
阅读全文
摘要:Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of th
阅读全文
摘要:Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the
阅读全文
摘要:Given an array A of integers, return true if and only if we can partition the array into three non-empty parts with equal sums. Formally, we can parti
阅读全文
摘要:Implement the BSTIterator class that represents an iterator over the in-order traversal of a binary search tree (BST): BSTIterator(TreeNode root) Init
阅读全文
摘要:A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are va
阅读全文
摘要:Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class
阅读全文
摘要:Serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted acr
阅读全文
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes
阅读全文
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia
阅读全文
摘要:You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You ca
阅读全文
摘要:The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value, and the median is the mean of th
阅读全文
摘要:Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or
阅读全文
摘要:Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or
阅读全文
摘要:旋转字符串。题意是给两个字符串A和B,请判断B是否是经由A旋转过若干次而得到的。例子, Example 1: Input: A = 'abcde', B = 'cdeab' Output: true Example 2: Input: A = 'abcde', B = 'abced' Output:
阅读全文
摘要:This is an interactive problem. You have a sorted array of unique elements and an unknown size. You do not have an access to the array but you can use
阅读全文
摘要:Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1: Input: nums = [1
阅读全文
摘要:Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.
阅读全文
摘要:Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an algorithm that runs in O(n) time and uses co
阅读全文
摘要:Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both cas
阅读全文
摘要:Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,
阅读全文
摘要:A permutation of an array of integers is an arrangement of its members into a sequence or linear order. For example, for arr = [1,2,3], the following
阅读全文
摘要:You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each li
阅读全文
摘要: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 maxim
阅读全文
摘要: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 maxim
阅读全文
摘要:There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where
阅读全文
摘要:Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top,
阅读全文
摘要:Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, pee
阅读全文
摘要:The boundary of a binary tree is the concatenation of the root, the left boundary, the leaves ordered from left-to-right, and the reverse order of the
阅读全文
摘要:You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: Le
阅读全文
摘要:Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initia
阅读全文

浙公网安备 33010602011771号