NEXT PERMUTATION | Leetcode | Know the Intuition behind the Algorithm | C++ | Java | Brute-Optimal

preview_player
Показать описание


This video's explanation tends to fail for some, so prefer watching the above lecture.

In case you are thinking to buy courses, please check below:

#dsa #leetcode #placements
Рекомендации по теме
Комментарии
Автор

Thank you striver ❤️ got placed at paytm and this was the first question asked in interview 😍😍

suryansh
Автор

Only this guy can clear my doubt, I always search a problem and I’m feel blessing when he was already made video on that algorithm

surajroy
Автор

Just a suggestion, algo is quite easy but watch this video 2 or 3 times to get a clear picture of the intuition.
Keep it up,

priyanshupandey
Автор

Trust me
You won't get a better explanation than this one.🔥

ashutoshtiwari
Автор

THIS IS ONE OF THE MOST UNDERRATED CHANNEL IN THE ASPECT OF CONTENT DUDE YOU ARE ACTUALLY MAKING OUR FUTURE SECURE !! THANKS A LOT !!!

Gamer_with_knowledge
Автор

Never thought of these type of intuition, absolutely brilliant.

amanbhadani
Автор

Simply brilliant..
I have not seen anyone explaining this beautifully.

AbhishekKumar-hkgb
Автор

I was stuck doing this question for many days but now u cleared my doubts .
Thanks for your effort

sreejanagrahari
Автор



This video's explanation tends to fail for some, so prefer watching the above lecture.

takeUforward
Автор

after understanding the problem and the great explanation by striver
also it tooks me 5-6 hourse literally
if anyone wants the python code u can refer


class Solution:
def nextPermutation(self, N, arr):
n = len(arr)
if n <= 1:
return

# 1st Step...
i = n-2
while i >= 0 and arr[i] >= arr[i+1]:
i -= 1
# ...

if i < 0:
# It shows that all the elements are in descending order.
arr[:] = arr[::-1] #for reversing the array
return arr
else:
# 2nd Step...
j = n-1
while arr[j] <= arr[i]:
j -= 1
# ...

# 3rd Step...
arr[i], arr[j] = arr[j], arr[i]
# ...

# 4th Step...
arr[i+1:] = sorted(arr[i+1:])
return arr

nqntrqb
Автор

instead of swapping first, we can reverse first, then to find the first greater element we can use upper bound. Time complexity will be O(n + logn) = O(n) only but runtime will be fast.

utsavsiddhpura
Автор

My potato brain did not understand this even after watching the video twice

chitranshsaxena
Автор

The explanation of the intuition just blew me, wow man, just wow.🔥

JAYPRAKASH-uyrg
Автор

Thumbnails are becoming great day by day...

swapnoneelduttamajumdar
Автор

I was watching this and thinking "there's no way there's any intuition to this" and was completely blown away by last..hats off

FallenAngels-mu
Автор

Wow!!! Mind blowing explanation! That too in nearly 10 min! I love this series :)

NaveenKumar-zpsy
Автор

please explain why at 2:36 even the element at 0th position also satisfies the condition of a[i]<a[i+1], so why didn't you consider that??

priyankas
Автор

Small error at line 8 java code u have to put j>i along with & . Try this [1, 3, 1]

manyasurve
Автор

literally best video for next permutation, thanks

zaid
Автор

One of the best explanations for this question on

prateeksingh