You are not logged in. Please login at www.codechef.com to post your questions!

×

Sherlock and cost... Hackerrank DP problem

0
1

Why does this code time out?? Link to the problem problem

Here is the solution with test cases (downloaded) ideone

asked 06 Apr '15, 10:56

anh1l1ator's gravatar image

6★anh1l1ator
142618
accept rate: 11%

edited 06 Apr '15, 11:05


-1

You are using recurse . instead first you need to check if this computation is already done or not . if not then recurse and save the result in some memo. otherwise use the stored value (what the point of using DP if you are doing same computation again and again) .

link

answered 06 Apr '15, 20:03

ayushtomar's gravatar image

5★ayushtomar
14115
accept rate: 4%

I have memoized it already ! :) Please see it again carefully....

(06 Apr '15, 20:35) anh1l1ator6★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×3,828
×2,220
×729
×310

question asked: 06 Apr '15, 10:56

question was seen: 6,637 times

last updated: 06 Apr '15, 20:36