Search in Rotated Sorted Array is a common problem recently asked in many tech companies like Paypal, VMware, Oracle etc.
It can be solved in logarithmic time complexity if we tweak binary search a bit. This question tests a programmers problem solving ability and their ability to identify problem related to key concepts like binary search.
You are expected to solve this problem within 20-30 mins, cover all the edge cases, use proper variable name and write clean and concise code.
I have explained the approach in details in this video.
Based on leetcode 33. Search in Rotated Sorted Array
leetcode.com/problems/search-...
problem statement:
Given an integer array nums sorted in ascending order, and an integer target.
Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
You should search for target in nums and if you found return its index, otherwise return -1.
You can buy us a coffee at : www.buymeacoffee.com/thetechg...
system design: • System Design | Distri...
DS for beginners: • Arrays Data Structures...
leetcode solutions: • Leetcode 84 | Largest ...
github: github.com/TheTechGranth/theg...
facebook group : / 741317603336313
twitter: / granthtech
2 ноя 2021