Given an array of integers, return indices of the two numbers such that they add up to ...
Given an array of integers, return indices of the two numbers such that they add up to ...
有 N 件物品和一個(gè)容量為 V 的背包。第 i 件物品的費(fèi)用是 c[i],價(jià)值是 w[i]。求解將哪些物品裝入背包可使價(jià)值總和最大 f[i][v]表示前 i 件物品恰放入一個(gè)...
要求要求恰裝滿(mǎn)背包在初始化時(shí)除了 f[0]為 0 其它 f[1..V]均設(shè)為-∞,這樣就可以保證最終得到的f[N]是一種恰好裝滿(mǎn)背包的最優(yōu)解。可以這樣理解:初始化的 f 數(shù)組...
有 N 種物品和一個(gè)容量為 V 的背包,每種物品都有無(wú)限件可用。第 i 種物品的費(fèi)用是 c[i],價(jià)值是 w[i]。求解將哪些物品裝入背包可使這些物品的費(fèi)用總和不超過(guò)背包容量...
There is a fence with n posts, each post can be painted with one of the k colors. You h...
Given a positive integer n, find the least number of perfect square numbers (for exampl...
Given an unsorted array of integers, find the length of longest increasing subsequence....
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ ...
Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by ...
Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by ...
You are given coins of different denominations and a total amount of money amount. Writ...
Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose pr...
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num c...
Given a positive integer n, break it into the sum of at least two positive integers and...
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix ...
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagra...
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How...
Given a m x n grid filled with non-negative numbers, find a path from top left to botto...
You are a professional robber planning to rob houses along a street. Each house has a c...
Note: This is an extension of House Robber.After robbing those houses on that street, t...