摘要:
#169 Majority Element Given an array of size n, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋ times. Yo 阅读全文
摘要:
#122 Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to 阅读全文
摘要:
#204 Count Primes Count the number of prime numbers less than a non-negative number, n. 题解:这道题如果对每个小于n的数都进行判断是否为素数并计数会超时,因此采用筛法来解这题。建一个数组,从2开始, 把其倍数小于 阅读全文
摘要:
#121 Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitte 阅读全文
摘要:
#104 Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from th 阅读全文