sir, i have implemented the same logic as taught in the hint video,but still i am getting tle in 2 test cases…here is the link to my code:
plz helpp!!
sir, i have implemented the same logic as taught in the hint video,but still i am getting tle in 2 test cases…here is the link to my code:
plz helpp!!
Thankyu sir…it worked!!.
@aman212yadav sir ,why do we need to pass input vector by reference as we are not changing anything into it…could you please explain…
check this https://www.tutorialspoint.com/differences-between-pass-by-value-and-pass-by-reference-in-cplusplus
@aman212yadav
thanks sir…it cleared my doubt…but i have one more doubt that is;
we are not changing anything in the vector in which we are taking the input…then why do we need to pass that by reference…passing “tree” vector by reference makes sense…but passing “arr” vector by referece does’nt make sense to me…(arr vector is the vector in which we are taking input int the code i have written).
it saves time .
if we pass by value then everytime copying of vector from old to new will take O(n) which is time consuming.
and if we pass by reference then it is O(1)
Ohh thats something new i just learned…thanks a lot sir…: