Explanation for the article: www.geeksforgeeks.org/find-the... Practice Problem Online Judge: practice.geeksforgeeks.org/pro... This video is contributed by Harshit Jain.
Пікірлер: 37
@amityadav-op4qv5 жыл бұрын
In the 2nd method , 1st for loop ,why i
@rithikroosen24164 жыл бұрын
public static void main(String[] args) { int arr[]={3,5,4,2,6,5,6,6,5,4,8,3}; minimumdistance(arr); // TODO Auto-generated method stub } static void minimumdistance(int a1[]) { int count=1,k=0,q=0,i=1,j=0; int size=a1.length; int n1=0,n=0; Scanner obj= new Scanner(System.in); System.out.println("Enter the first number in an array "); n1=obj.nextInt(); System.out.println("Enter the second number in an array "); n=obj.nextInt(); for(i=0;i
@divyeshbhartiya4 жыл бұрын
When min_dist is equal to 1,can we break the loop there itself? Coz min_dist can not be less than 1.
@abhijeet21533 жыл бұрын
correct .
@suryakantsapkal82424 жыл бұрын
Hey, thanks for this video.!! Method 2 looks good for all the arrays which contains X and Y values. You also need to handle the scenario where if array does not contain any of the X or Y value then min distance should be 0.
@avnishgupta87317 жыл бұрын
Hi Can't we solve it using the stack as to count how many we have pop after one of the value we are able to find out.
@youcan49137 жыл бұрын
Sir i think some modification should be done in the second program. after storing the index in prev u should increament i =i+1;
@mukeshsinghdance73324 жыл бұрын
I also noticed same
@PraveenKumar-ft2kr6 жыл бұрын
Really best👍👍👌
@kasthurishravankumarhpc5 жыл бұрын
Thank you sir.
@vishalmahavratayajula96584 жыл бұрын
At 7:55 you said we should not find variable x, but that is not correct. We can still find it and update the prev. That's how you would get the min distance for same like this 61234678. where 6 and 8 are the 2 given no.s
@charchilgupta7 жыл бұрын
Hello GFG , I am a big fan of you guys and really appreciate your hard work. Just a suggestion - Could you please make your videos little bit more interesting.....by interesting I mean the way of presentation can be improved ...(like using videoscribe or other animations and also the tone of speaker can be more dynamic).
@GeeksforGeeksVideos7 жыл бұрын
Thank you, Charchil! We are trying out different ways of presentation. Soon, you will see different kinds of videos on our channel. And, if you are interested in contributing to our channel, please drop us an email at "videos@geeksforgeeks.org"
@sangnguyenn2367 Жыл бұрын
Thank you so much 🥰🥰🥰🥰🥰
@hermesmercuriustrismegistu48414 жыл бұрын
thx a lot
@SCRIPTSAG4 жыл бұрын
This is enough practice for array
@shobhitchaturvediindia8 жыл бұрын
Nice explanation
@GeeksforGeeksVideos7 жыл бұрын
Thank you, Shobhit!
@jiniamitra75934 жыл бұрын
Java HashMap will give o(n)
@PradeepPant0073 жыл бұрын
Method 1- More Simplified class Solution { int minDist(int a[], int n, int x, int y) { int mindis=Integer.MAX_VALUE; boolean g=false; for(int i=0;i
@dhruvmittal8018 Жыл бұрын
i'm trying to run same code but don't know why this is giving me wrong answer class Solution{ public: int minDist(int a[], int n, int x, int y) { int i; int prev; int min_dis=INT_MAX; for(i=0;i
@nanditabrahmbhatt622 жыл бұрын
//alternate solution public class mindistance { public static void main(String[] args) { int a[]={1,2,3,2,4,6,1}; int index1=-1,index2=-1,len=Integer.MAX_VALUE; for(int i=0;i-1&&index2>-1) { if (Math.abs(index1-index2)
@karandeeplamba80044 жыл бұрын
k
@evolvingbackwards86375 жыл бұрын
why cant we use this??????? #include using namespace std; int main(){ int a[] = {2, 5, 3, 5, 4, 4, 2, 3}; int differ=0 , pos1=0 , pos2=0 , final_diff=0; int num1 = 3 , num2 = 2; for(int i=0;ipos1){ differ = pos2-pos1; } if(pos1>pos2){ differ = pos1-pos2; } if(final_diff > differ || final_diff==0){ final_diff = differ; } } cout
@shenth273 жыл бұрын
Thanks for the video. Just one suggestion though, going through the lecture notes before the code walkthrough is unnecessary, it's just repeating the same thing. All we care about is the code - how the logic is written.
@shreyaswaghmare76905 жыл бұрын
Approach 2: Medium
@harshil90594 жыл бұрын
presentation skills are pathetic actually. Presenter is just reading the slides.
@sunnybajaj49933 жыл бұрын
Agar meri job lag gayi acchi to aapko laddu bhejuga