10 2018 档案
摘要: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 warme
阅读全文
摘要:Given an integer, return its base 7 string representation. Example 1: Example 2: Note: The input will be in range of [-1e7, 1e7]. 给一个整数,返回它的七进制数。 解法1:
阅读全文
摘要:We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself. Now, given an integer n, write
阅读全文
摘要:Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. Examp
阅读全文
摘要:Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects
阅读全文
摘要:In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascend
阅读全文
摘要:Print a binary tree in an m*n 2D string array following these rules: Example 1: Example 2: Example 3: Note: The height of binary tree is in the range
阅读全文
摘要:Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: Construct the maximum tree by the given array a
阅读全文
摘要:Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Note: 给一个非空二叉树,返回每层的平均值组成的数组。 解
阅读全文
摘要:Given the running logs of n functions that are executed in a nonpreemptive single threaded CPU, find the exclusive time of these functions. Each funct
阅读全文
摘要:There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up (u), down (d), left (l) or right (r), but it
阅读全文
摘要:There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop roll
阅读全文
摘要:There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop roll
阅读全文
摘要:Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer nand is grea
阅读全文
摘要:Given a circular array (the next element of the last element is the first element of the array), print the Next Greater Number for every element. The
阅读全文
摘要:You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1'
阅读全文
摘要:You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rota
阅读全文
摘要:You can keep inputting the password, the password will automatically be matched against the last n digits entered. For example, assuming the password
阅读全文
摘要:International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a"maps to ".-", "b" maps
阅读全文
摘要:In a given integer array A, we must move every element of A to either list B or list C. (B and C initially start empty.) Return true if and only if af
阅读全文
摘要:In a directed graph, we start at some node and every turn, walk along a directed edge of the graph. If we reach a node that is terminal (that is, it h
阅读全文
摘要:You'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 ston
阅读全文
摘要:On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square represented by 0. A move consists of choosing 0 and a 4
阅读全文
摘要: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
阅读全文
摘要:In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. There is at least one empty seat, and at least
阅读全文
摘要:Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Example 1: Input: S =
阅读全文
摘要:Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Example 2: Note: 给一个整数数组,找出乘积最大的3个数,返回这
阅读全文
摘要:有 n 个硬币排成一条线。两个参赛者轮流从右边依次拿走 1 或 2 个硬币,直到没有硬币为止。拿到最后一枚硬币的人获胜。 请判定 第一个玩家 是输还是赢? n = 1, 返回 true.n = 2, 返回 true.n = 3, 返回 false.n = 4, 返回 true.n = 5, 返回 t
阅读全文
摘要:有 n 个不同价值的硬币排成一条线。两个参赛者轮流从左边依次拿走 1 或 2 个硬币,直到没有硬币为止。计算两个人分别拿到的硬币总价值,价值高的人获胜。 请判定 第一个玩家 是输还是赢? 样例给定数组 A = [1,2,2], 返回 true.给定数组 A = [1,2,4], 返回 false.
阅读全文
摘要:2D平面上,有m个人(P),n辆自行车(B),还有空白(O)满足以下条件1.m < n. 2.不存在两个人,到同一辆自行车距离相等, 距离用abs(x1-x2) + abs(y1-y2)定义3.每个人尽量找离自己最近的自行车,一旦某辆自行车被占,其他人只能找别的自行车。例OPOBOOPOOOOOOO
阅读全文
摘要:Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2
阅读全文
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumR
阅读全文
摘要:You are given a campus map with the Google buildings, roads and Google bikes. You have to help the employee find the nearest Google bike. Campus map:
阅读全文
摘要:What are the differences between a process and a thread? How are they similar? How can 2 threads communicate? How can 2 process communicate? Both proc
阅读全文
摘要:Given a family tree for a few generations for the entire population and two people write a routine that will find out if they are blood related. Sibli
阅读全文
摘要:Implement a magic directory with buildDict, and search methods. For the method buildDict, you'll be given a list of non-repetitive words to build a di
阅读全文
摘要:You are given an integer array sorted in ascending order (may contain duplicates), you need to split them into several subsequences, where each subseq
阅读全文
摘要:We have a list of bus routes. Each routes[i] is a bus route that the i-th bus repeats forever. For example if routes[0] = [1, 5, 7], this means that t
阅读全文
摘要:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 whic
阅读全文
摘要:Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any
阅读全文
摘要:Given a list of strings, you could concatenate these strings together into a loop, where for each string you could choose to reverse it or not. Among
阅读全文
摘要:Given a binary tree, you need to find the length of Longest Consecutive Path in Binary Tree. Especially, this path can be either increasing or decreas
阅读全文
摘要:Given a k-ary tree, find the length of the longest consecutive sequence path. The path could be start and end at any node in the treeExampleAn example
阅读全文
摘要:Given a grid where each entry is only 0 or 1, find the number of corner rectangles. A corner rectangle is 4 distinct 1s on the grid that form an axis-
阅读全文
摘要:There are N workers. The i-th worker has a quality[i] and a minimum wage expectation wage[i]. Now we want to hire exactly K workers to form a paid gro
阅读全文
摘要:N cars are going to the same destination along a one lane road. The destination is target miles away. Each car i has a constant speed speed[i] (in mil
阅读全文
摘要:In an exam room, there are N seats in a single row, numbered 0, 1, 2, ..., N-1. When a student enters the room, they must sit in the seat that maximiz
阅读全文
摘要:You 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 pe
阅读全文
摘要:This problem is an interactive problem new to the LeetCode platform. We are given a word list of unique words, each word is 6 letters long, and one wo
阅读全文
摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1and s2. Example 1: Example 2: 给定字符串s1, s2, s3,求s3是否可以由s1和s2交错形成。 解法:DP动态规划, 递推公式为
阅读全文
摘要:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representati
阅读全文
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the
阅读全文
摘要:Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Example 1: Example 2: Follow up: A
阅读全文
摘要:Given a binary tree, count the number of uni-value subtrees. A Uni-value subtree means all nodes of the subtree have the same value. For example:Given
阅读全文
摘要:Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the roo
阅读全文
摘要:Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For
阅读全文
摘要:In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this n
阅读全文
摘要:Given 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 bottom. Example
阅读全文
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e
阅读全文
摘要:Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has the following content: Your script should output t
阅读全文
摘要:Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: By calling next repeatedly until
阅读全文
摘要:Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... Example 1: Example 2: Note:You may assume all input has v
阅读全文
摘要:Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... For example, given nums = [3, 5, 2, 1, 6, 4],
阅读全文
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating
阅读全文
摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to
阅读全文
摘要:Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutati
阅读全文
摘要:Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and the
阅读全文
摘要:Design a Phone Directory which supports the following operations: Example: 设计一个电话目录有3个功能,get: 给出一个没有使用的电话号码,check: 查验一个电话号码是否被使用了,release: 释放一个电话号码,使其
阅读全文
摘要:On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length. Now, we add K
阅读全文
摘要:Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If there isn't one, return 0 instead. Example 1: Given
阅读全文
摘要:In an election, the i-th vote was cast for persons[i] at time times[i]. Now, we would like to implement the following query function: TopVotedCandidat
阅读全文
摘要:Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list
阅读全文
摘要:Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes
阅读全文
摘要:Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example: Note: 新题中没有提示,老版的有。
阅读全文
摘要:Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example
阅读全文
摘要:In this problem, a tree is an undirected graph that is connected and has no cycles. The given input is a graph that started as a tree with N nodes (wi
阅读全文
摘要:Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given
阅读全文
摘要:You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups b
阅读全文
摘要:Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the vali
阅读全文
摘要:This question is about implementing a basic elimination algorithm for Candy Crush. Given a 2D integer array board representing the grid of candy, diff
阅读全文
摘要:Given a set of points in the plane. the convex hull of the set is the smallest convex polygon that contains all the points of it. https://www.geeksfor
阅读全文
摘要:https://www.careercup.com/question?id=5103530547347456 Given a list of nodes, each with a left child and a right child (they can be null), determine i
阅读全文
摘要:Considering that I'ld would like to spread a promotion message across all people in twitter. Assuming the ideal case, if a person tweets a message, th
阅读全文
摘要:Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If the
阅读全文
摘要:Given a singly linked list, return a random node's value from the linked list. Each node must have the same probability of being chosen. Follow up:Wha
阅读全文
摘要:Shuffle a set of numbers without duplicates. Example: 给一个没有重复数字的数组,实现重置和洗牌的功能。 解法:遍历数组每个位置,每次都随机生成一个坐标位置,然后交换当前位置和随机位置的数字,这样如果数组有n个数字,那么也随机交换了n组位置,从而达
阅读全文
摘要:Given a robot cleaner in a room modeled as a grid. Each cell in the grid can be empty or blocked. The robot cleaner with 4 given APIs can move forward
阅读全文
摘要:A group of friends went on holiday and sometimes lent each other money. For example, Alice paid for Bill's lunch for 10.ThenlaterChrisgaveAlice10.Then
阅读全文
摘要:Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For example,
阅读全文
摘要:Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For example,
阅读全文
摘要:Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. For example,MovingAverage m = new Mo
阅读全文
摘要:In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach o
阅读全文
摘要:Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree. You may assume each number in the seq
阅读全文
摘要:This is a follow up of Shortest Word Distance. The only difference is now you are given the list of words and your method will be called repeatedly ma
阅读全文
摘要:This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as word2. Given a list of words and two words word1
阅读全文
摘要:Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. For example,Assume that words =
阅读全文
摘要:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. Note: The algorithm should run in linear time and in O(1) spa
阅读全文
摘要:Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a lette
阅读全文
摘要:Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a lette
阅读全文
摘要:Given an integer n, return the number of trailing zeroes in n!. Example 1: Example 2: Note: Your solution should be in logarithmic time complexity. 给一
阅读全文
摘要:In the following, every capital letter represents some hexadecimal digit from 0 to f. The red-green-blue color "#AABBCC" can be written as "#ABC" in s
阅读全文