boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - dp problem on mit
相关主题
这道题DP怎么做阿
分享2个电面题目
一个面试问题
Maximum Sum of Increasing Sequence
那个leetcode上头得distinct subsequence什么意思
leetcode一题没看明白
面试题count # of increasing subsequences of String求解
求解这个动态规划题
大家帮忙解释一个 LeetCode DP (distinct subsequences)
Question on leetcode Distinct Subsequences
相关话题的讨论汇总
话题: cities话题: person话题: xab话题: sequence
进入JobHunting版参与讨论
1 (共1页)
b*******e
发帖数: 217
1
Two-Person Traversal of a Sequence of Cities. You are given an ordered
sequence of n cities, and the distances between every pair of cities. You
must partition the cities into two subsequences (not necessarily contiguous)
such that person A visits all cities in the first subsequence (in order),
person B visits all cities in the second subsequence (in order), and such
that the sum of the total distances travelled by A and B is minimized.
Assume that person A and person B start initially at the first city in their
respective subsequences.
t****a
发帖数: 1212
2
很有趣的题目。有测试数据和答案吗?
b*******e
发帖数: 217
3
my recursive function is
Xba(i) = Min { Xab(i-1) + D(i-2, i) ; Xba(i-1) + D(i-1, i);
Xaa(i-1) + D(i-1, i) ; Xab(i-2) + D(i-3, i) + D(i-2, i-1);
Xab(i-3) + D(i-4, i) + D(i-3, i-1),
....
Xab(1) + D(1, i) + D(1, i-1)}
Where ba indicates i-1 th city is visited by b and ith city is visited by a.
aa indicates i-1 th city visited by a and ith city also visited by a.
ab, and bb following the same.
Following same method,
We can have the recursive function for Xaa(i), Xab(i) and Xbb(i).
The final min is Min(Xba(n), Xaa(n), Xbb(n), Xab(n))

【在 t****a 的大作中提到】
: 很有趣的题目。有测试数据和答案吗?
1 (共1页)
进入JobHunting版参与讨论
相关主题
Question on leetcode Distinct Subsequences
花了一上午把get all palindromic subsequences debug完了
Google onsite问题
一朋友被Google的电面干掉了 (转载)
贴一下我google第一轮店面的题目
google题
寻找子序列/子段落
Facebook interview 面经
请教一道题
问一道简单DP题
相关话题的讨论汇总
话题: cities话题: person话题: xab话题: sequence