help me out to understand the complexity of the program step by steps
Merge_list complexity
we are traversing both the list once
so lets say size of LL 1 is n
size of LL 2 is m
then total time is O(N+M)
and space is O(N+M)
since the stack is used for recursive calls
@chhavibansal we here don’t care about the inputs and other function that we have implemented to make the linked list . ?
we have derived the complexity in this way only
we have n let 1 2 3 4 5
and m let 1 4 2 2 2 1 4
here we are compare each is list element with another list elements so we have to traverse both the lists so o(N+M) RIght ???
no
yes thats correct
@chhavibansal thanks u so much u always clear all my doubt in a better way!
One help more can u guide me, please .
I am facing to understand the concepts of timelimit exceed TLE. I m not able to get how to understand that when writing algorithm how to check the algorithm is working in a given time limit
yr dry run se to kabhi kabhi he pata chal sakta h
u might need to add print statemtents as to where the TLE is happening ( thats how i usually debug)
and practice se pata chal jayega ( thoda intution)
It is my pleasure to help you.
Wish you good luck.
@chhavibansal print statement kha par?
constraints se pta nhi chalta prateek bhaiya ne kuch video main discuss kiye tha…
ha
vo to h
like vo to ki kis time complexity ki algo lagani h
like 10^9 ho to logn
that is covered in one of the video bhai Prateek BHaiya
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.