Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 58 #127

Closed
vaskoz opened this issue Oct 18, 2018 · 1 comment
Closed

Day 58 #127

vaskoz opened this issue Oct 18, 2018 · 1 comment
Assignees

Comments

@vaskoz
Copy link
Owner

vaskoz commented Oct 18, 2018

Good morning! Here's your coding interview problem for today.

This problem was asked by Amazon.

An sorted array of integers was rotated an unknown number of times.

Given such an array, find the index of the element in the array in faster than linear time. If the element doesn't exist in the array, return null.

For example, given the array [13, 18, 25, 2, 8, 10] and the element 8, return 4 (the index of 8 in the array).

You can assume all the integers in the array are unique.

@vaskoz vaskoz self-assigned this Oct 18, 2018
@vaskoz
Copy link
Owner Author

vaskoz commented Oct 18, 2018

Simply a modified binary search that can deal with rotation. Will run in O(log N) since it's binary search.

@vaskoz vaskoz mentioned this issue Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant