随笔分类 - Coding Made Simple
Lectures by Tushar Roy on Youtube.
摘要:Given an array of positive number, find maximum sum subsequence such that elements in this subsequence are not adjacent to each other. Recursive formu
阅读全文
摘要:Find longest bitonic subsequence in given array. Bitonic subsequence first increases then decreases. Same problem link Longest Bitonic Subsequence
阅读全文
摘要:Given a staircase and give you can take 1 or 2 steps at a time, how many ways you can reach nth step. Same problem link. Climbing Stairs
阅读全文
摘要:Given a 2D immutable array, Write an efficient program to support any given sub-rectangle sum query in this 2D matrix. A simple solution is to add eac
阅读全文
摘要:Given a 2D matrix where every element is either ‘O’ or ‘X’, find the largest subsquare surrounded by ‘X’. Examples: Solution 1. O(N^4) runtime. Consid
阅读全文
摘要:Given a number n, find the total number of numbers from 0 to 2^n - 1 which do not have consecutive 1s in their binary representation. Solution. This p
阅读全文
摘要:Given n which is total number of keys in BST, how many BSTs can be formed with n keys. Solution 1. Recursion Solution 2. Dynamic Programming
阅读全文
摘要:Given a 2 dimensional matrix, how many ways you can reach bottom right from top left provided you can only move down and right.
阅读全文
摘要:Count Number of Binary Tree Possible given Preorder Sequence. For example, given preorder sequence of {10, 11, 9, 12, 13, 14}, the total possible numb
阅读全文
摘要:Given coins of certain denominations and a total, how many ways these coins can be combined to get the total. Dynamic Programming solution State: T[i]
阅读全文
摘要:Given coins of certain denominations and a total, how many minimum coins would you need to make this total? Dynamic Programming solution State: T[i][j
阅读全文
摘要:Given some number of floors and some number of eggs, what is the minimum number of attempts it will take to find out from which floor egg will break.
阅读全文
摘要:Given certain jobs with start and end time and amount you make on finishing the job, find the maximum value you can make by scheduling jobs in non-ove
阅读全文
摘要:Given a rod of length and prices at which different length of this rod can sell, how do you cut this rod to maximize profit. Solution. Dynamic Program
阅读全文
摘要:Given two strings, find longest common substring between them. Solution 1. Brute force search, O(n^2 * m), O(1) memory Algorithm. O(n^2) runtime to fi
阅读全文
摘要:Given keys and frequency at which these keys are searched, how would you create a binary search tree from these keys such that the cost of searching i
阅读全文
摘要:Given a set of distinct integers, return all possible subsets. Notice Elements in a subset must be in non-descending order. The solution set must not
阅读全文
摘要:Given a set of non negative integers and a target value, find if there exists a subset in the given set whose sum is target. Solution 1. Enumerate all
阅读全文
摘要:Given some matrices, in what order you would multiply them to minimize cost of multiplication. The following problem formulation is extracted from thi
阅读全文
摘要:Given two strings, find the longest common subsequence (LCS). Your code should return the length of LCS. Given two strings, find the longest common su
阅读全文

浙公网安备 33010602011771号