Leetcode Linked List in Binary Tree

Problem link>>

My code generating TLE can u plz help why so ??
and how can I memorize it
my code>>>

hello @joshisanjay8467

there is logical mistake.

ss

they want continuous matching like here in the image 4->2-> 8
but in ur solution u may skip some of the nodes of the tree.

a) one simple idea for this problem is go to each node and then check whether list can be placed from this nodes onwards or not.
like this =>

b)
second approach is based on pattern matching algorithm .
read about kmp

consider this sqew tree

1 
  \
    1 
     \
      1
       \
        2

if list is 1->1->2 then ur logic will never find a match. becuase u skipped some nodes from the tree

complete logic is wrong !! thankyou bhaiya done using first approach dfs on every node

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.