Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

mountain array leetcode

class Solution:
    def peakIndexInMountainArray(self, arr: List[int]) -> int:
        start = 0
        end = len(arr)-1
        
        while (start < end):
            mid = start + (end-start)//2
            if (arr[mid]>arr[mid+1]):
                end = mid
            else: start = mid+1
        return start
Comment

mountain array leetcode

class Solution {    
    public static int peakIndexInMountainArray(int[] arr) {
        int start = 0;
        int end = arr.length-1;

        while(start < end){
            int mid = start + (end-start)/2;

            if (arr[mid] > arr[mid+1]) end = mid;
            else start = mid+1;
        }
        return start;
    }
}
Comment

PREVIOUS NEXT
Code Example
Python :: ocaml returns the last element of a list 
Python :: how to print tables using python 
Python :: odoo manifest 
Python :: fill_between matplotlib 
Python :: list in python 3 
Python :: how to create a function in python 
Python :: using csv module how to read perticular lines in csv 
Python :: python game github 
Python :: pandas change string column to datetime 
Python :: format number differences in python 
Python :: how to add string in csv in python 
Python :: get element from string with deliminator python 
Python :: int to float python 
Python :: items of list 
Python :: python max counts 
Python :: difference between 2 dataframes 
Python :: split string by special characters python 
Python :: select column in pandas dataframe 
Python :: How can I get the output of each layer in Tensorflow 2 
Python :: get hours from datetime.timedelta in python (Django) 
Python :: Generate hashed passwords for ansible 
Python :: series object has no attribute split 
Python :: python types of loops 
Python :: remove element from list python by value 
Python :: plt.scatter background color 
Python :: python latest version 64 bit 
Python :: python tex box 
Python :: create QAction with icon in pyqt 
Python :: reverse range python 
Python :: nltk python how to tokenize text 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =