Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a method to perform a binary search on a rotated sorted array.

Medium

Problem Statement

Write a method to perform a binary search on a rotated sorted array.

Sample Input

Array: [4, 5, 6, 7, 0, 1, 2], Target: 6

Sample Output

2

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined rotated array and target array = [4, 5, 6, 7, 0, 1, 2] target = 6 # Your logic here
Log in or sign up to run or submit your code.Log inSign up
Input
Array: [4, 5, 6, 7, 0, 1, 2], Target: 6
Expected Output
2