bool binarySearch(int arr[], int s, int e, int key) { if (s > e) return false; int mid = s + (e - s) / 2; if (arr[mid] == key) return true; if (arr[mid] < key) return binarySearch(arr, mid + 1, e, key); else return binarySearch(arr, s, mid - 1, key); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter