記錄: 2017

0

Majority Element

Majority ElementGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the major

0

Excel Sheet Column Title

Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet. For Example:12345671 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB

0

Min Stack

Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top()

0

Single Number

Single NumberGiven an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without

0

Valid Palindrome

Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example:12"A man, a plan, a canal: Panama" is a palindrome.

0

Best Time to Buy and Sell Stock

Best Time to Buy and Sell StockSay you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and

0

Pascal's Triangle II

Pascal’s Triangle IIGiven an index k, return the kth row of the Pascal’s triangle. For example, given k = 3,Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space?

0

Pascal's Triangle

Pascal’s TriangleGiven numRows, generate the first numRows of Pascal’s triangle. For example:Given numRows = 5, Return 1234567[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]] 提示 解題應用 A

0

Path Sum

Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example:Given the below binary tree an