Another interesting DP. Lesson learnt: how you define state is crucial.. 1. if DP[i] is defined as, longest wiggle(up\down) subseq AT number i, you will have O(n^2) solution class Solution { struct Rec { Rec(): mlen_dw(), mlen_up(){} Rec(int ldw, int…
http://community.topcoder.com/stat?c=problem_statement&pm=13147 此题关键在于发现ABAB的组合最多有26*26种,可以穷举,然后用判断子序列~ #include <vector> #include <iostream> using namespace std; class LongWordsDiv2 { public: string find(string word) { for (int i = 0; i &…