2037. Minimum Number of Moves to Seat Everyone | leetcode daily challenge | DSA | Hindi

Поділитися
Вставка
  • Опубліковано 11 чер 2024
  • Problem Name:
    2037. Minimum Number of Moves to Seat Everyone
    Problem Statement:
    There are n seats and n students in a room. You are given an array seats of length n, where seats[i] is the position of the ith seat. You are also given the array students of length n, where students[j] is the position of the jth student.
    You may perform the following move any number of times:
    Increase or decrease the position of the ith student by 1 (i.e., moving the ith student from position x to x + 1 or x - 1)
    Return the minimum number of moves required to move each student to a seat such that no two students are in the same seat.
    Note that there may be multiple seats or students in the same position at the beginning.
    Problem link:
    leetcode.com/problems/minimum...
    Java Plus DSA Placement Course Playlist:
    • Java and DSA Course Pl...
    Java Plus DSA Sheet:
    docs.google.com/spreadsheets/...
    Notes:
    github.com/Tiwarishashwat/Jav...
    Telegram Link:
    shashwattiwari.page.link/tele...
    Ultimate Recursion Series Playlist:
    • Recursion and Backtrac...
    Instagram Handle: (@shashwat_tiwari_st)
    shashwattiwari.page.link/shas...
    Samsung Interview Experience:
    • I cracked Samsung | SR...
    Company Tags:
    Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
    Timestamp:
    0:00 - Introduction
    #ShashwatTiwari #coding​​ #problemsolving​

КОМЕНТАРІ • 12

  • @shivendrasingh8520
    @shivendrasingh8520 Місяць тому +2

    bhaiya you are one the best teacher bhaiya underrated matlab koi aise nahi alag alag approaches batata hai bhaiya

  • @abdullahintisar7365
    @abdullahintisar7365 Місяць тому

    i did it like this understand the problem from you and tried to do it.
    int minMovesToSeat(vector& seats, vector& students)
    {
    sort(seats.begin(),seats.end());
    sort(students.begin(), students.end());
    int diff = 0;
    for(int i = 0; i< seats.size();i++)
    {
    diff += (abs(seats[i]-students[i]));
    }
    return diff;
    }
    time complexity = nlogn

  • @RohitKumar-dz8dh
    @RohitKumar-dz8dh Місяць тому +1

    Thanks 😊

  • @aggarwalsachin4854
    @aggarwalsachin4854 Місяць тому +1

    good explaination

  • @vishalsuryan1797
    @vishalsuryan1797 Місяць тому +2

    Bhaiya I was able to think of the brute force solution within 2 mins and coded it exactly as you did

  • @SMS_news
    @SMS_news Місяць тому

    Vi a graph ar dp ki playlist chalu kor diji a joldi😊😊

  • @PrakashRai-ff3pr
    @PrakashRai-ff3pr Місяць тому

    sir which u explained before coding i get it but plz after code try to explain code too sometimes samj nhi aata ...

  • @vedictechyog
    @vedictechyog Місяць тому

    please provide the code also

  • @SulemanbhashaDodmni
    @SulemanbhashaDodmni Місяць тому

    sulemanbhasha dodmani

  • @SulemanbhashaDodmni
    @SulemanbhashaDodmni Місяць тому

    linkedin pe message kiya hu dekhe nhi ap