05 2016 档案
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word
阅读全文
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example,Given nums = [0, 1,
阅读全文
摘要: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 comple
阅读全文
摘要:Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Given num = 16, return true. Given num = 5, return fa
阅读全文
摘要: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? 1162261467 =
阅读全文
摘要:Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element i
阅读全文
摘要:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 ston
阅读全文
摘要:Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t =
阅读全文
摘要:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements
阅读全文
摘要:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, giv
阅读全文
摘要: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 binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: But the fol
阅读全文
摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c
阅读全文
摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up:Could you do this in-place? 倒置数组后,交换x,y的
阅读全文
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f
阅读全文
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area. For example, given the following mat
阅读全文
摘要: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. For exa
阅读全文
摘要:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and r
阅读全文
摘要: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
阅读全文
摘要:Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assum
阅读全文