JavaScript one line code.

  • -1

    I don't think this problem is for JS. I saw someone's (n + logn) solution, was wondering why not just compare one by one, resulting in O(n). Not sure the question is asking the index in the sorted array or in the rotated array. I tried js build-in array method, and surprisingly my answer passed and beats 60%.

    var search = function(nums, target) {
    	return nums.indexOf(target);

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.