
动态规划
njudongchen
这个作者很懒,什么都没留下…
展开
-
微软2017 第四题
变种版背包问题: 可以这么理解 父节点背包总重cap,每个子节点拥有重量为Wi,价值为Vi的石头,问将背包填满的最小价值. 解决上述问题,再利用递归就可以求出最小的花费:求上述问题的思路: 设子节点所有的石头重量和为sum,子节点的个数为count; 申请dp[count][sum+1]的数组,dp[i][j]表示用0-i的石头填满j的最小花费.不能填满的花费为-1; 所以dp[0][0]原创 2017-04-08 22:33:27 · 340 阅读 · 0 评论 -
unique-path
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bot原创 2017-04-03 15:17:17 · 385 阅读 · 0 评论 -
candy
There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: Each child must have at least one can原创 2017-04-03 17:29:09 · 521 阅读 · 0 评论 -
distinct-subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by deleting some (can be none)原创 2017-04-18 23:14:34 · 382 阅读 · 0 评论 -
path-sum-i&ii
题目描述Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. For example: Given the below binary tree andsum = 22, 5 / \原创 2017-04-18 23:34:20 · 275 阅读 · 0 评论 -
palindrome-partitioning-ii
Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s =”aab”, Return1since原创 2017-04-17 00:09:48 · 520 阅读 · 0 评论 -
微软夏令营笔试测验第一题 Array Partition
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Given an integer array A1, A2 … AN, you are asked to split the array into three continuous parts: A1, A2 … Ap | Ap+1, Ap+2, … Aq | Aq+1, Aq+2, … AN.Let S1, S2原创 2017-07-20 13:18:51 · 598 阅读 · 0 评论