03 2021 档案
摘要:Given a binary tree root. Split the binary tree into two subtrees by removing 1 edge such that the product of the sums of the subtrees are maximized.
阅读全文
摘要: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 the root of a binary tree, each node has a value from 0 to 25 representing the letters 'a' to 'z': a value of 0 represents 'a', a value of 1 rep
阅读全文
摘要:A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles i
阅读全文
摘要:Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bot
阅读全文
摘要:Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a val (int) and
阅读全文
摘要: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
阅读全文
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. You may return the answer in any order. Example 1: Input: n
阅读全文
摘要:The figure shows the tree view of directories in Windows File Explorer. When a file is selected, there is a file path shown in the above navigation ba
阅读全文
摘要:A substring is a continuous part of a string. A subsequence is the part of a string that might be continuous or not but the order of the elements is m
阅读全文
摘要:The Fibonacci sequence Fn is defined by Fn+2=Fn+1+Fn for n≥0, with F0=0 and F1=1. The closest Fibonacci number is defined as the Fib
阅读全文
摘要:Professional Ability Test (PAT) consists of several series of subject tests. Each test is divided into several levels. Level A is a prerequisite (前置要求
阅读全文
摘要:The left-view of a binary tree is a list of nodes obtained by looking at the tree from left hand side and from top down. For example, given a tree sho
阅读全文
摘要:The land is for sale in CyberCity, and is divided into several pieces. Here it is assumed that each piece of land has exactly two neighboring pieces,
阅读全文
摘要:PP milk (盆盆奶)is Pandas' favorite. They would line up to enjoy it as show in the picture. On the other hand, they could drink in peace only if they bel
阅读全文
摘要:When the input is much too large to fit into memory, we have to do external sorting instead of internal sorting. One of the key steps in external sort
阅读全文
摘要:A safari park(野生动物园)has K species of animals, and is divided into N regions. The managers hope to spread the animals to all the regions, but not the s
阅读全文
摘要:A game of numbers has the following rules: at the beginning, two distinct positive integers are given by the judge. Then each player in turn must give
阅读全文
摘要:The above picture is from Sina Weibo, showing May 23rd, 2019 as a very cool "Prime Day". That is, not only that the corresponding number of the date 2
阅读全文
摘要:A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices sharing the same edge have the same color. A colo
阅读全文
摘要:A registration card number of PAT consists of 4 parts: the 1st letter represents the test level, namely, T for the top level, A for advance and B for
阅读全文
摘要:The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shor
阅读全文
摘要:When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in s
阅读全文
摘要:Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1
阅读全文
摘要:In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the
阅读全文
摘要:This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed grap
阅读全文
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Exampl
阅读全文
摘要:Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen nu
阅读全文
摘要:You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list
阅读全文
摘要:Given the head of a linked list, remove the nth node from the end of the list and return its head. Follow up: Could you do this in one pass? Example 1
阅读全文
摘要:Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the thr
阅读全文
摘要:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the s
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Exampl
阅读全文
摘要:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is
阅读全文
摘要:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is
阅读全文
摘要:Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function). The algorithm for myAt
阅读全文
摘要:Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-23
阅读全文
摘要: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
阅读全文
摘要:Given a string s, return the longest palindromic substring in s. Example 1: Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer. Examp
阅读全文
摘要:vector begin()返回指向第一个元素的迭代器 end()返回指向最后一个元素的迭代器 rbegin()返回指向最后一个元素的迭代器 rend()返回指向第一个元素的迭代器 size()返回容器的元素的个数 max_size()返回容器的最大的元素的个数 resize()重新调整容器的容量,
阅读全文
摘要:Given a string s containing only digits, return all possible valid IP addresses that can be obtained from s. You can return them in any order. A valid
阅读全文
摘要:Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Retu
阅读全文
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9
阅读全文
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example 1: Input: n = 3 Output: ["((()))","(()
阅读全文
摘要:The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return al
阅读全文
摘要:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any
阅读全文