Comments
0

The solution for 414B can be more efficient regarding memory we dont need 2D dp we can easily do it using 1D dp

we can make in-place changes in the dp array...

as dp[i] (sequences starting with $$$i$$$) only transitions from multiples j where $$$j \ge i$$$, and I iterate $$$i$$$ from $$$1 \to N$$$, fetching dp[j] (where $$$j \gt i$$$) guarantees we are reading the value from the previous step ($$$k-1$$$)

this makes the space complexity from O(n*k) to O(n) only

TC is still O(k*nlog(n))

  • runtime — 78ms
  • memory — 100KB
Code

website : https://tesseract-2k26.vercel.app/sandbox

First two questions on website were practice sample questions

It should have been KERNEL instead of KERNAL :_(

Contest Link : Link

Let;s Go!