This video explains a very important interview question which is how to find the next greater element for all the elements in an array in linear time efficiently. The efficient approach makes use of stack to solve this problem in linear time. I have also explained the brute-force approach which takes O(N2) time but the efficient approach only takes O(N) time. CODE LINK is given below. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)
CODE LINK: gist.github.co...
Негізгі бет Next greater element in an array
Пікірлер: 138