From c83b2d1f72df641c5b46c54e7c98339dbb440ae4 Mon Sep 17 00:00:00 2001 From: Asia Osman <115678840+AsiaOsman06@users.noreply.github.com> Date: Thu, 21 Aug 2025 21:46:12 -0500 Subject: [PATCH] Update Sample Asia Osman --- Sample | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/Sample b/Sample index ceae9f98..8c46e98d 100644 --- a/Sample +++ b/Sample @@ -1,7 +1,50 @@ -// Time Complexity : +// Time Complexity : log(n) // Space Complexity : // Did this code successfully run on Leetcode : // Any problem you faced while coding this : +class Solution { + public int search(int[] nums, int target) { + int left=-10000; //max=-10000 because max can not be less than -10,000 + int idxleft=-1; //finding the idx where the max value is at + int right=10000; // min=10,000 because there can;t be min greater than 10,000 + int idxright=-1; //finding the idx where the min value is at. + for(int i=0; ileft){ // finding if the current value is > max + left=nums[i]; + idxleft=i; + } + if(nums[i]nums[idxright] && idxright != nums.length-1){ + return findidx(nums,idxleft,idxright+1,target); + }else if(target>nums[idxright] && idxright==nums.length-1 || target