随笔分类 - Level 2
摘要:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum pro
阅读全文
摘要:Count the number of prime numbers less than a non-negative number, n
阅读全文
摘要:Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequen
阅读全文
摘要: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
阅读全文
摘要:Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the following rules: A move is guaranteed to be valid and
阅读全文
摘要: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
阅读全文
摘要:Calculate the a^n % b where a, b and n are all 32bit integers. Calculate the a^n % b where a, b and n are all 32bit integers. Calculate the a^n % b wh
阅读全文
摘要:Check Power of 2 Using O(1) time to check whether an integer n is a power of 2. Check Power of 2 Using O(1) time to check whether an integer n is a po
阅读全文
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target va
阅读全文
摘要:The structure of Expression Tree is a binary tree to evaluate certain expressions.All leaves of the Expression Tree have an number string value. All n
阅读全文
摘要: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 (decimal - e.g. 3.72) number that is passed in as a string, return the binary representation that is passed in as a string. If the fractional
阅读全文
摘要: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? Ye
阅读全文
摘要:Spiral Matrix I Given an integer n, generate a square matrix filled with elements from 1 to n^2 in spiral order. Example Given n = 3, You should retur
阅读全文
摘要:Find Minimum in Rotated Sorted Array I Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4
阅读全文
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e
阅读全文
摘要:Given an absolute path for a file (Unix-style), simplify it. Have you met this question in a real interview? Yes Example "/home/", => "/home" "/a/./b/
阅读全文
摘要:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have
阅读全文
摘要:Print numbers from 1 to the largest number with N digits by recursion. Notice It's pretty easy to do recursion like: recursion(i) { if i > largest num
阅读全文
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Have you met this question in a real interview? Yes Exam
阅读全文

浙公网安备 33010602011771号