原创 Leetcode:27.Remove Element

題目:Given an array and a value, remove all instances of that value in-place and return the new length. Do not alloca

原创 Leetcode:442. Find All Duplicates in an Array 找數組中的重複數字

Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Fi

原创 Leetcode:713.Subarray Product Less Than K

題目描述: 題目: Your are given an array of positive integers nums. Count and print the number of (contiguous) subarrays

原创 Leetcode: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 permi

原创 Leetcode:204. Count Primes 求素數的優化問題

Description: Count the number of prime numbers less than a non-negative number, n. Credits: Special thanks to @mit

原创 Leetcode:202. Happy Number

Write an algorithm to determine if a number is “happy”. A happy number is a number defined by the following process

原创 Leetcode:112. Path Sum (求Tree中是否存在路徑的和等於給定值)

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values alo

原创 Leetcode:485. Max Consecutive Ones 找二進制串連續1最多是多少

Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Out

原创 Leetcode:167. Two Sum II - Input array is sorted 求數組中的兩個數的和等於給定值,求這兩個數的下標

Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a s

原创 Leetcode:349. Intersection of Two Arrays

Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2,

原创 Leetcode:36.Valid Sudoku 初始化數獨數組是否合法判斷

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially fille

原创 Leetcode:513. Find Bottom Left Tree Value

Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Input: 2 / \ 1 3 Output

原创 Leetcode:350. Intersection of Two Arrays II 求兩個數組的交集

Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2,

原创 Leetcode:475. Heaters (利用二分binary search)

題目: Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to w

原创 Leetcode:283. Move Zeroes 把數組中爲0的元素移到最後

描述:Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of t