thefarzibruno's blog

By thefarzibruno, 11 years ago, In English

Can any help me give a solution using top down (memo + recursion) technique,for some reason my solution isn't counting all the possible answers,please help me as i'm new to dp. http://mirror.codeforces.com/problemset/problem/163/A http://ideone.com/AEMNUw

Tags dp
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
11 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Your rec(i, 0) actually counts only such pairs where x starts at position i. You never increase i unless s[i] == s[j];. res += rec(i, 0) for all i < s.size();