摘要:
Given an array of integers, find the subarray with smallest sum.Return the sum of the subarray.Have you met this question in a real interview? YesExam... 阅读全文
摘要:
Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? Recursion: 1 阅读全文
摘要:
Given a permutation which may contain repeated numbers, find its index in all the permutations of these numbers, which are ordered in lexicographical ... 阅读全文
摘要:
Given a permutation which contains no repeated number, find its index in all the permutations of these numbers, which are ordered in lexicographical o... 阅读全文
摘要:
Given n pieces of wood with length L[i] (integer array). Cut them into small pieces to guarantee you could have equal or more than k pieces with the s... 阅读全文
摘要:
Given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (e g , M becomes a s... 阅读全文
摘要:
Given a directed graph, design an algorithm to find out whether there is a route between two nodes.Have you met this question in a real interview? Yes... 阅读全文
摘要:
Determine the number of bits required to flip if you want to convert integer n to integer m.Have you met this question in a real interview? YesExample... 阅读全文
摘要:
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 n... 阅读全文
摘要:
Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first number and last number.Have you met this question in... 阅读全文
摘要:
iven a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value in t... 阅读全文
摘要:
Given an array of integers and a number k, the majority number is the number that occurs more than 1/k of the size of the array.Find it.Have you met t... 阅读全文
摘要:
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by upda... 阅读全文
摘要:
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k 0 && n-i-1>=count-j && res[j-1]arr2... 阅读全文
摘要:
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assum... 阅读全文
摘要:
Adopted approach: start from each building, try to reach all 0. Alternertive approch can be start from each 0, try to reach all buildings. Which is wa 阅读全文
摘要:
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your... 阅读全文
摘要:
You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smal 阅读全文
摘要:
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).If two nodes are in the same... 阅读全文
摘要:
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every ... 阅读全文
摘要:
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 o... 阅读全文
摘要:
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloon... 阅读全文
摘要:
Hint: build graph first, also buil indegree array, then find leaf and remove them among their neighbors, level by level. Until left less 2 nodes 这道题跟一 阅读全文
摘要:
Write a function to generate the generalized abbreviations of a word.Example:Given word = "word", return the following list (order does not matter):["... 阅读全文
摘要:
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee... 阅读全文
摘要:
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complet... 阅读全文
摘要:
Given two sparse matrices A and B, return the result of AB.You may assume that A's column number is equal to B's row number.Example:A = [ [ 1, 0, 0],... 阅读全文
摘要:
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may cont 阅读全文
摘要:
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected ... 阅读全文
摘要:
Union Find Princeton's lecture note on Union Find in Algorithms and Data Structures It is a well organized note with clear illustration describing fro 阅读全文
摘要:
Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the f 阅读全文
摘要:
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 阅读全文
摘要:
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one bla 阅读全文
摘要:
讲解一: 用一个数组来存 the smallest tail of all increasing subsequences with length i+1 in tails[i]. For example, say we have nums = [4,5,6,3], then all the ava 阅读全文
摘要:
Referring this post: https://leetcode.com/problems/serialize-and-deserialize-binary-tree/discuss/74253/Easy-to-understand-Java-Solution But instead us 阅读全文