Leetcode 1752. Check if Array Is Sorted and Rotated [Java]

preview_player
Показать описание
This is the "Check if Array Is Sorted and Rotated" leetcode question explanation in Java. Do you know how to check if an array is sorted and rotated without actually sorting and rotating it? In this case, check out this video where you will see how to do it with O(N) time complexity.

Please write in the comments below which leetcode problem you want me to solve next.

And remember, a leetcode a day keeps unemployment away!

Thanks for watching!
Рекомендации по теме
Комментарии
Автор

This is smart, I went about it finding the point in the array where it stops being non-decreasing, and then checking the rest of the array is non-decreasing, AND then that the last element is less or equal to the first, but yours is way easier. GG

spaghettiking
Автор

Best explanation on YouTube I was stuck in this problem but your video helped me to understand the solution..

turing_machine
Автор

Helpful! Love you man! 🥰 Its really difficult sometimes, but after watching this video seems a lot more clear now. Thanks

darkelixir
Автор

damn man...thats so nice approach, i loved it

yashwantkr
Автор

Line 16: Char 5: error: non-void function does not return a value in all control paths [-Werror, -Wreturn-type]
}
^
1 error generated.

asianguy
Автор

f, i coded everything but couldn't get the if condition -- it was going outside the boundary tqsm

yassreyt
Автор

Even [30, 20, 10, 50, 35] is a sorted and rotated array but the code doesn't take this array into consideration. Do we only consider the ascending order?

pakhisingh
Автор

good video.. it really helped !
thanks :)

siddharthdagar
Автор

i dunno, when i will code like this....

sanjays
Автор

why count is greater than 1 it shiuld be zero

asianguy