All tags
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.
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
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.
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.
Coin Change
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.
Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.
Coin Sum
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.
Array Chunking
Given an array
and a size
, split the array items into a list
of arrays of the given size.