Pass the Pillow | 2 Approaches | Easy Explanations | Leetcode 2582 | codestorywithMIK

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



Duration: 24:09
4,319 views
217


Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 46th Video of our Playlist "Leetcode Easy : Popular Interview Problems" by codestorywithMIK

In this video we will try to solve a good practice problem : Pass the Pillow | 2 Approaches | Easy Explanations | Leetcode 2582 | 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 : Pass the Pillow | 2 Approaches | Easy Explanations | Leetcode 2582 | codestorywithMIK
Company Tags : MICROSOFT
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/pass-th...


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 (Simple Simulation)

Time Complexity: O(time)
Space Complexity: O(1)
Description: This approach simulates the passing of the pillow in real-time. We maintain two variables, idx for the current position and dir for the direction (either forward or backward). As long as there is remaining time, we update the position and direction based on the current state, decrementing the time with each step until the time runs out. This approach is straightforward but may be inefficient for large time values due to its linear complexity.
Approach 2 (Simple Maths)

Time Complexity: O(1)
Space Complexity: O(1)
Description: This approach uses mathematical calculations to determine the final position without simulating each step. It calculates the number of full rounds of passing the pillow (totalFullRounds) and the remaining time (timeLeft). Depending on whether the number of full rounds is even or odd, it adjusts the final position accordingly. This method is highly efficient with constant time complexity, making it suitable for larger inputs.

✨ Timelines✨
00:00 - Introduction

#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 #newyear2024




Other Videos By codestorywithMIK


2024-07-12Number of Atoms | Made Easy | Full Dry Run | Leetcode 726 | Google | codestorywithMIK
2024-07-12Minimum Cost for Cutting Cake I & II | Thought Process | Leetcode 3218 | 3219 | codestorywithMIK
2024-07-12Robot Collisions | Made Easy | Dry Run | Leetcode 2751 | codestorywithMIK
2024-07-12Minimum Insertion Steps to Make a String Palindrome | Blue Print | DP On Strings | Leetcode 1312
2024-07-11Maximum Score From Removing Substrings | 2 Approaches | With Proof | Leetcode 1717
2024-07-09Reverse Substrings Between Each Pair of Parentheses | 2 Approaches | Leetcode 1190 |codestorywithMIK
2024-07-08Crawler Log Folder | 2 Approaches | Dry Runs | Leetcode 1598 | codestorywithMIK
2024-07-07Average Waiting Time | Simple Simulation | Leetcode 1701 | codestorywithMIK
2024-07-06Range Update Query | Lazy Propagation | Segment Tree Concepts & Qns | Video 7 | codestorywithMIK
2024-07-06Find the Winner of the Circular Game | 3 Approaches | Leetcode 1823 | codestorywithMIK
2024-07-05Pass the Pillow | 2 Approaches | Easy Explanations | Leetcode 2582 | codestorywithMIK
2024-07-02Minimum Difference Between Largest and Smallest Value in Three Moves | 2 Approaches | Leetcode 1509
2024-07-02Merge Nodes in Between Zeros | 2 Approaches | Leap Of Faith | Leetcode 2181 | codestorywithMIK
2024-06-30Intersection of Two Arrays II | 2 Approaches | Easy Explanations | Leetcode 350 | codestorywithMIK
2024-06-29Longest Palindromic Subsequence | Using Blue Print | DP On Strings | Leetcode 516 | DP Concepts - 25
2024-06-28Query Sum II | Segment Tree Concepts & Qns | Video 5 | codestorywithMIK
2024-06-28Longest Palindromic Substring | Recursion Memo | Bottom Up | DP On Strings | Leetcode 5
2024-06-28Range Minimum Query | Segment Tree Concepts & Qns | Video 6 | codestorywithMIK
2024-06-27All Ancestors of a Node in a Directed Acyclic Graph | 3 Approaches | Leetcode 2192 |codestorywithMIK
2024-06-26Maximum Total Importance of Roads | Thought Process | Leetcode 2285 | codestorywithMIK
2024-06-25Find Center of Star Graph | 2 Simple Approaches | Leetcode 1791 | codestorywithMIK