wow you just changed my prespective of seeing jump game problems how you come up with using graph data structure
@crackfaang Жыл бұрын
Don't be surprised at the lengths I am willing to go to avoid using DP
@zahraaskarzadeh5618 Жыл бұрын
Thanks
@AnandKumar-kz3ls Жыл бұрын
Hi , im getting TLE in c++ Edit: i just passed the reference of graph now it get accepted int dfs(int u,vector& graph,vector& dp){ if(dp[u]!=-1) return dp[u]; int jumps=1; for (auto v : graph[u]) jumps=max(jumps,1+dfs(v,graph,dp)); return dp[u]=jumps; } int maxJumps(vector& arr, int d) { int n=arr.size(); vector dp(n,-1); vector graph(n); for(int i=0;i
@crackfaang Жыл бұрын
Glad you got it working. I can’t guarantee other languages work with the solution given. The cutoffs are often different and some code is not transferable