Binary Search - (Recursive + Iterative) | Leetcode-704 | Explanation ➕ Live Coding

preview_player
Показать описание
This is the 12th Video on our Binary Search Playlist.
In this video we will try to solve the most famous, classic, basic Problem "Binary Search" (Leetcode - 704)

We will solve is using Iterative and Recursive approaches

We will do live coding after explanation and see if we are able to pass all the test cases.

Problem Name : Binary Search
Company Tags : Almost all companies :-)

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish
Рекомендации по теме
Комментарии
Автор

5:30 hn sir please 🥺
Bohot confusion rehti hai mereko binary search ki variations mai

divyangdheer
Автор

Congratulations bhaiya for 3k
Thanku for the video bhaiya❤

UmeshBisht-ikli
Автор

Thanks bhai. Java Implementations:

Iterative:

class Solution {

public int search(int[] nums, int target) {

int s=0;
int e = nums.length - 1;

int mid = -1;

while(s <= e) {

mid = s + (e-s)/2;

if(nums[mid] == target) {

return mid;

}

else if(nums[mid] > target) {

e = mid-1;

}

else {

s = mid+1;

}

}

return -1;

}
}


Recursive:

class Solution {

private int bSearch(int nums[], int target, int s, int e) {

if(s > e) return -1;

int mid = s + (e-s)/2;

if(nums[mid] == target) return mid;

if(nums[mid] > target) {

return bSearch(nums, target, s, mid-1);

}

return bSearch(nums, target, mid+1, e);

}

public int search(int[] nums, int target) {

return bSearch(nums, target, 0, nums.length-1);
}

}

JJ-tpdd
Автор

Bro can u also discuss codeforces round problems?

udaykumarchetla
Автор

Bro leetcode 1171 and 92.
Tomorrow is Sunday so please make a video on it.

manimanohar_
Автор

Bro aapke CP journey pe ek video bana do please.

molyoxide
Автор

Waiting for Dijkstra bhai.. aj ayega ya kal? Aaj please 🙈

JJ-tpdd
welcome to shbcf.ru