09 2020 档案
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Return 0 if the array contains less than 2 el
阅读全文
摘要:In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the ent
阅读全文
摘要:Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed). Example 1: Input: root = [1,3,2,5,3,null,9]
阅读全文
摘要:Given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi. You can attend an event i at a
阅读全文
摘要:We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the bui
阅读全文
摘要:A kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is born. The ki
阅读全文
摘要:You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the
阅读全文
摘要:The Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: "../" : Move to the p
阅读全文
摘要: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
阅读全文
摘要:You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A
阅读全文
摘要:Given an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may retu
阅读全文
摘要:Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head. The steps of the insertion sort algorit
阅读全文
摘要:Given a node from a Circular Linked List which is sorted in ascending order, write a function to insert a value insertVal into the list such that it r
阅读全文
摘要:Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST. Assume a BST is define
阅读全文
摘要:Given a list of the scores of different students, items, where items[i] = [IDi, scorei] represents one score from a student with IDi, calculate each s
阅读全文
摘要:Given an array nums sorted in non-decreasing order, and a number target, return True if and only if target is a majority element. A majority element i
阅读全文
摘要:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. Example 1: Input: nums = [3,2,3] Output: [3] Example 2: Input
阅读全文
摘要:You are given the root of a binary tree with n nodes where each node in the tree has node.val coins. There are n coins in total throughout the whole t
阅读全文
摘要:Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus
阅读全文
摘要:You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee. Find th
阅读全文
摘要:You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete
阅读全文
摘要:An integer has sequential digits if and only if each digit in the number is one more than the previous digit. Return a sorted list of all the integers
阅读全文
摘要:You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k. Find the maximum profit you can
阅读全文
摘要:You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete
阅读全文
摘要:Given an integer array nums, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array wil
阅读全文
摘要:On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: "G": go straight 1 unit; "L
阅读全文
摘要:Given the root of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in to_delete, we are left with a fo
阅读全文
摘要:Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n. Example 1: Input: nums = [3,10,5,25,2,8] Output:
阅读全文
摘要:There are n flights that are labeled from 1 to n. You are given an array of flight bookings bookings, where bookings[i] = [firsti, lasti, seatsi] repr
阅读全文
摘要:Given a positive integer N, how many ways can we write it as a sum of consecutive positive integers? Example 1: Input: 5 Output: 2 Explanation: 5 = 5
阅读全文
摘要:Given a node in a binary search tree, find the in-order successor of that node in the BST. If that node has no in-order successor, return null. The su
阅读全文
摘要:Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output: 6 Example 2: Inp
阅读全文
摘要:You are playing the Bulls and Cows game with your friend. You write down a secret number and ask your friend to guess what the number is. When your fr
阅读全文
摘要:Given a root of an N-ary tree, return a deep copy (clone) of the tree. Each node in the n-ary tree contains a val (int) and a list (List[Node]) of its
阅读全文
摘要:Given an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target. The answer is
阅读全文
摘要:A conveyor belt has packages that must be shipped from one port to another within days days. The ith package on the conveyor belt has a weight of weig
阅读全文
摘要:Koko loves to eat bananas. There are N piles of bananas, the i-th pile has piles[i] bananas. The guards have gone and will come back in H hours. Koko
阅读全文
摘要:You are given the root of a binary tree where each node has a value 0 or 1. Each root-to-leaf path represents a binary number starting with the most s
阅读全文
摘要:Given an array arr of positive integers sorted in a strictly increasing order, and an integer k. Find the kth positive integer that is missing from th
阅读全文
摘要:On a campus represented as a 2D grid, there are N workers and M bikes, with N <= M. Each worker and bike is a 2D coordinate on this grid. Our goal is
阅读全文
摘要:Given a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in
阅读全文
摘要:There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west). You are given the integer capacit
阅读全文
摘要:Given the coordinates of two rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles. The first rectangle is defined
阅读全文
摘要:You are given two images, img1 and img2, represented as binary, square matrices of size n x n. A binary matrix has only 0s and 1s as values. We transl
阅读全文
摘要:An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the c
阅读全文
摘要: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
阅读全文
摘要:Given two binary search trees root1 and root2. Return a list containing all the integers from both trees sorted in ascending order. Example 1: Input:
阅读全文
摘要:Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. In one move, you can increment or
阅读全文
摘要:Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. In one move, you can increment n
阅读全文
摘要:Given a file and assume that you can only read the file using a given method read4, implement a method read to read n characters. Your method read may
阅读全文
摘要:Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters. Method read4: The API rea
阅读全文
摘要:Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into sets of k consecutive numbersReturn Tru
阅读全文
摘要:You are given the root of a binary search tree (BST), where exactly two nodes of the tree were swapped by mistake. Recover the tree without changing i
阅读全文

浙公网安备 33010602011771号