https://practice.geeksforgeeks.org/problems/smaller-on-left2036/0
Bhaiya @phantom.
By this logic it is giving TLE. because constraints are very high…
Can not able to solve this question with less time complexity.
https://practice.geeksforgeeks.org/problems/smaller-on-left2036/0
Bhaiya @phantom.
By this logic it is giving TLE. because constraints are very high…
Can not able to solve this question with less time complexity.
ok i am giving u a hint
u can use BST or heap to solve that question
traversing will take n and searching will take logn
so net complexity is
nlogn
I have used heap to Solve it.
But still TLE.
u r using map to store
u are using a for loop then inside it iterating the map so this will take a 0n^2 approach
use BST to store and search this u can do it in logn time
so net complexity becam nlogn
If still not unserstand i will gave u code 