Find the Student that Will Replace the Chalk | 2 Ways | Leetcode 1894 | codestorywithMIK

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=RG-vw6IzVuU



Duration: 0:00
5,484 views
280


Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 105th Video of our Playlist "Array 1D/2D : Popular Interview Problems" by codestorywithMIK

In this video we will try to solve a simple Simulation Array Problem : Find the Student that Will Replace the Chalk | 2 Ways | Leetcode 1894 | codestorywithMIK

I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.

Problem Name : Find the Student that Will Replace the Chalk | 2 Ways | Leetcode 1894 | codestorywithMIK
Company Tags : will update soon
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/find-th...


My Personal Blog & Behind The Scenes -    / @weekendwithmik  
My DP Concepts Playlist :    • Roadmap for DP | How to Start DP ? | ...  
My Graph Concepts Playlist :    • Graph Concepts & Qns - 1 : Graph will...  
My Recursion Concepts Playlist :    • Introduction | Recursion Concepts And...  
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Intervie...
Instagram :   / codestorywithmik  
Facebook :   / 100090524295846  
Twitter :   / cswithmik  
Subscribe to my channel :    / @codestorywithmik  

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

Summary :
Approach 1: Simulation (TLE)

Description: This approach simulates the chalk usage by iterating through the students in a loop and subtracting their chalk requirements from k until k becomes less than a student's chalk requirement. The simulation continues until the condition is met.
Time Complexity: O(k/sum * n) — where sum is the total sum of chalk requirements in one full iteration and n is the number of students. This can result in a Time Limit Exceeded (TLE) error for large inputs, as k might be very large.
Space Complexity: O(1) — The approach only uses a constant amount of extra space.
Approach 2: Remainder Optimization

Description: Instead of simulating the entire process, this approach calculates the total chalk required for one complete round of all students (totalChalkSum). It then computes the remainder of k when divided by totalChalkSum (remainChalk). This allows us to reduce the problem to a smaller equivalent by only considering the remaining chalk. Finally, it finds the first student whose chalk requirement exceeds remainChalk.
Time Complexity: O(n) — The total chalk sum is computed in one pass, and finding the student who runs out of chalk takes another pass.
Space Complexity: O(1) — This approach also only uses a constant amount of extra space.

✨ Timelines✨
00:00 - Introduction
0:17 - Problem Explanation
2:52 - Simulation Approach - TLE
6:52 - Improved Approach - Accepted
13:20 - Coding it up

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik




Other Videos By codestorywithMIK


2024-09-14DSA Shorts with MIK - 3
2024-09-13Longest Subarray With Maximum Bitwise AND | Simple Observation | Leetcode 2419 | codestorywithMIK
2024-09-12XOR Queries of a Subarray | Simple Explanation | Leetcode 1310 | codestorywithMIK
2024-09-11Count the Number of Consistent Strings | Using Bit Manipulation | Leetcode 1684 | codestorywithMIK
2024-09-09Insert Greatest Common Divisors in Linked List | 2 Approaches | Leetcode 2807 | codestorywithMIK
2024-09-08Maximum Number of Moves to Kill All Pawns | Step By Step Detailed | Leetcode 3283 | codestorywithMIK
2024-09-08Leetcode Contest Qn-4 ka Khauf
2024-09-06Linked List in Binary Tree | Easy | Dry Run | Leetcode 1367 | codestorywithMIK
2024-09-05Delete Nodes From Linked List Present in Array | Simple | Dry Run | Leetcode 3217 | codestorywithMIK
2024-09-04Walking Robot Simulation | Detailed Simulation | Leetcode 874 | codestorywithMIK
2024-09-01Find the Student that Will Replace the Chalk | 2 Ways | Leetcode 1894 | codestorywithMIK
2024-09-01DSA Shorts with MIK - 2
2024-08-31Convert 1D Array Into 2D Array | 2 Approaches | Leetcode 2022 | codestorywithMIK
2024-08-30Palindrome Partitioning II | Using Blue Print | DP On Strings | Leetcode 132 | DP Concepts & Qns-28
2024-08-30Modify Graph Edge Weights | Using Dijkstra | Thought Process | Leetcode 2699 | codestorywithMIK
2024-08-29Most Stones Removed with Same Row or Column | Using DSU | DRY RUN | Leetcode 947 | codestorywithMIK
2024-08-27Count Sub Islands | Easiest Thought Process | Leetcode 1905 | codestorywithMIK
2024-08-25Travel Tales
2024-08-24Find the Closest Palindrome | Simple Observations | Leetcode 564 | codestorywithMIK
2024-08-22Fraction Addition and Subtraction | Simple Simulation | Leetcode 592 | codestorywithMIK
2024-08-22DSA Shorts with MIK - 1