All problems
Lattice Paths
Count the number of unique paths to travel from the top left corner to the bottom right corner of a lattice of M x N squares.
Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist.
Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longest increasing subsequence.
Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.
If there is no common prefix, return an empty string “".
Example 1:
Input: [“flower”,“flow”,“flight”] Output: “fl”
Example 2:
Input: [“dog”,“racecar”,“car”] Output: "” Explanation: There is no common prefix among the input strings.
Note:
All given inputs are in lowercase letters a-z.
Solution
Longest Common Subsequence
Given two strings text1 and text2, return the length of their longest common subsequence.
Factorial
Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 65432*1 which is 720.
Capitalization
Given a phrase
, capitalize every word.
Adjacent Cells
Eight houses, represented as cells, are arranged in a straight line. Each day every cell competes with its adjacent cells (neighbors). An integer value of 1 represents an active cell and a value of 0 represents an inactive cell. If the neighbors on both the sides of a cell are either active or inactive, the cell becomes inactive on the next day; otherwise the cell becomes active. The two cells on each end have a single adjacent cell, so assume that the unoccupied space on the opposite side is an inactive cell. Even after updating the cell state, consider its previous state when updating the state of other cells. The state information of all cells should be updated simultaneously.
Write an algorithm to output the state of the cells after the given number of days.
Relative Sort Array
Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1.
Combination Sum
Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.
The same repeated number may be chosen from candidates unlimited number of times.