Search in Rotated Sorted Array | Binary Search | Animated DSA Explanation in Java
AlgoRung
0:00 / 0:00
Search in Rotated Sorted Array | Binary Search | Animated DSA Explanation in Java
0 просмотров · 8 дн. назад
AlgoRung
9 подписчиков
0 просмотров · 8 дн. назад
Search in Rotated Sorted Array (Medium) explained step by step with animations: the idea, a brute force, the optimal solution and its complexity, with Java code.
A sorted array of distinct integers was rotated at an unknown pivot. Given a target, return its index or -1, in O(log n) time.
Java code + notes: https://algorung.com/dsa/binary-searc...
Practise it with spaced revision: https://algorung.com/app/problems/sea...
Chapters
0:00 The problem
0:25 Check every element
0:45 One half is always sorted
1:32 Searching for 8
2:34 Searching for 20
3:44 Complexity
3:59 Edge cases & recap
Similar problems
• Find How Many Times Array is Rotated: https://algorung.com/dsa/binary-searc...
• Find Minimum in Rotated Sorted Array: https://algorung.com/dsa/binary-searc...
• Find Minimum in Rotated Sorted Array II: https://algorung.com/dsa/binary-searc...
• Search in Rotated Sorted Array II: https://algorung.com/dsa/binary-searc...
More Binary Search problems: https://algorung.com/dsa/binary-search
All patterns: https://algorung.com/patterns
#DSA #BinarySearch #SearchinRotatedSortedArray #Java #CodingInterview #LeetCode #AlgoRung