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 exist in the

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

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

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:

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"

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.

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

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

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

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

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

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