Skip to content

Instantly share code, notes, and snippets.

@Ephraimiyanda
Created February 28, 2026 22:39
Show Gist options
  • Select an option

  • Save Ephraimiyanda/f2f189e1a9b5f8dd9bf1b18f3aa17715 to your computer and use it in GitHub Desktop.

Select an option

Save Ephraimiyanda/f2f189e1a9b5f8dd9bf1b18f3aa17715 to your computer and use it in GitHub Desktop.
Search in Rotated Sorted Array II

Question

Approach

I loop through the array to check if a number is equal to the target

Complexity

  • Time complexity:O(1)

  • Space complexity:O(N)

Code

function search(nums: number[], target: number): boolean {
    for(let i=0;i<nums.length;i++){
        if(nums[i]===target){
            return true
        }
    }
    return false
};
scrnli_vOeyp76Y5wJazj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment