LeetCode LeetCode Digest - Random Pick Series 398. Random Pick Index Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must

LeetCode LeetCode Digest - Move Zeroes 283. Move Zeroes Problem 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, given nums = [0, 1, 0, 3, 12], after calling your function, nums should

LeetCode LeetCode Digest - BrainTeaser Series 292. Nim Game Problem 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 stones. The one who removes the last stone will

LeetCode LeetCode Digest - Reverse String Series 344. Reverse String Problem: Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "olleh". Solution 1 Using list comprehension: class Solution(object): def reverseString(self, s): """ :type

LeetCode LeetCode Digest - Valid Number 65. Valid Number Problem: Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true Note: It is intended

LeetCode LeetCode Digest - Reverse Integer 7. Reverse Integer Problem: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you thought about this? Here are some good questions to ask before coding. Bonus points for you if you have already thought through this!

LeetCode LeetCode Digest - String to Integer (atoi) 8. String to Integer (atoi) Problem: Implement atoi to convert a string to an integer. Requirements for atoi: The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial

LeetCode LeetCode Digest - Dynamic Programming Series 70. Climbing Stairs Problem: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Classical Dynamic Programming Problem.

LeetCode LeetCode Digest - House Robber Series 198. House Robber Problem: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and

LeetCode LeetCode - Containing Water Series Container With Most Water - Problem 11 Problem: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0)

LeetCode LeetCode - Ugly Number Series Ugly Number - Problem 263 Problem: 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 example, 6, 8 are ugly while 14 is not ugly since

LeetCode LeetCode - Calculator Series Problem: Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces . You may assume that the given expression is always valid. Some examples: "