Word Break 2 Leetcode

Problem Link: https://leetcode.com/problems/word-break-ii/
My code is failing 3 test cases can u please help why?
my code>>>
https://ide.codingblocks.com/s/475482

hello @joshisanjay8467
check now->

Okay got that but bhaiya but It was a DP question and I did it without memorization still 0ms solution maybe weak constraints . If I am not wrong for memorization I will create 2d DP using string s and curr as state ??? Plz tell me I am correct or not ?

yeah, but for this problem 1 dp is sufficient ,
dp[i]= all possible answers when only [i…n-1] part of string is considered.

okay I will try to implement 1D dp in it and will see and bhaiya one core doubt : I am from ECE so never did OS so I am preparing from GFG only will that be sufficient?

yeah gfg + sanchit jain os videos (knowledge gate youtube channel ) is sufficient.

1 Like

okay bhaiya thankyou!

Bhaiya couldn’t figure out how can memoize the above modified code u sent I am thinking to return vector(string) every time and using a map keeping key as ‘s’ and mapping key s to vector(string). Please help

yeah do that only…
it will be convenient.

okay bhaiya doing that way !