https://ide.codingblocks.com/s/384071 - my code
I’m getting a TLE for last few test cases. How can I optimize this code ?
https://ide.codingblocks.com/s/384071 - my code
I’m getting a TLE for last few test cases. How can I optimize this code ?
hello @nidhigupta847
pass ur word string by reference and an index i (i is position of current character that u want to match. if it matches then in next function call pass i+1) .
base case if(i==word.size()) return true
Still getting TLE…
pls share ur updated code
pass visited by reference
Still getting TLE…
check now->
did following optimisations
a) passed everthing by refrence
b)
search for new path only when ur answer is still false.
c) use only one visited vector instead of creating new n *m(creation of vector is time consuming ) vector for each new state.
Thanks…
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.