- 895
- 3 571 523
codestorywithMIK
India
Registrace 19. 07. 2013
- Also available on topmate.io for 1-1 sessions - topmate.io/mazhar_mik (Currently Inactive due to tight schedule)
- I am on a mission to make a Super Resource for Interview Prep for everyone. đ One stop Solution for :
------- System Design
------- Data Structures and Algorithms
- I specialize for building INTUITION and giving reasons behind each and every line.
- I am on a mission to make a Super Resource for Interview Prep for everyone. đ One stop Solution for :
------- System Design
------- Data Structures and Algorithms
- I specialize for building INTUITION and giving reasons behind each and every line.
Crawler Log Folder | 2 Approaches | Dry Runs | Leetcode 1598 | codestorywithMIK
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 48th Video of our Playlist "Leetcode Easy : Popular Interview Problems" by codestorywithMIK
In this video we will try to solve a good practice problem : Water Bottles | 2 Approaches | Dry Runs | Leetcode 1598 | 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 : Water Bottles | 2 Approaches | Dry Runs | Leetcode 1598 | codestorywithMIK
Company Tags : Google, and some other company Online Assessment problem with slight variation
My solutions on Github(C++ & JAVA) : github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Stack/Easy/Crawler%20Log%20Folder.cpp
Leetcode Link : leetcode.com/problems/crawler-log-folder/description
My DP Concepts Playlist : czcams.com/video/7eLMOE1jnls/video.html
My Graph Concepts Playlist : czcams.com/video/5JGiZnr6B5w/video.html
My Recursion Concepts Playlist : czcams.com/video/pfb1Zduesi8/video.html
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Interview_DS_Algo
Instagram : codestorywithmik
Facebook : people/codestorywithmik/100090524295846/
Twitter : CSwithMIK
Subscribe to my channel : www.youtube.com/@codestorywithMIK
âââŠâââŠââââŠââŠâŠâŠâŠââââ
âââŁâââââŁââŁââŁââŁâââŁââŁ
â âââââââ ââââŁâââââââŁ
âââ©âââ©ââ©ââ©ââ©âââ©ââ©ââ
Summary :
Approach-1: Using Simple Simulation
Description: This approach uses a single integer variable depth to simulate the traversal of folders. The depth variable is incremented when entering a folder and decremented when moving up a directory ("../"), ensuring it doesn't go below zero. The "./" operations are ignored as they do not change the directory.
Time Complexity: O(n), where n is the number of operations. Each operation is processed once.
Space Complexity: O(1), as only a single integer variable is used regardless of the input size.
Approach-2: Using Stack for Simulation
Description: This approach uses a stack to simulate the traversal of folders. Each folder name is pushed onto the stack, and when encountering "../", the stack is popped if it's not empty. The "./" operations are ignored. The size of the stack at the end represents the current depth in the folder structure.
Time Complexity: O(n), where n is the number of operations. Each operation is processed once.
Space Complexity: O(n), as the stack can potentially grow up to the number of operations if no "../" commands are encountered.
Summary
Both approaches efficiently simulate the traversal of the folder structure based on the operations given. The first approach uses a single integer to keep track of the depth, resulting in constant space usage, making it more space-efficient. The second approach uses a stack, which is more intuitive in terms of simulating folder traversal but requires additional space proportional to the number of operations. Both have the same time complexity of O(n).
âš 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
This is the 48th Video of our Playlist "Leetcode Easy : Popular Interview Problems" by codestorywithMIK
In this video we will try to solve a good practice problem : Water Bottles | 2 Approaches | Dry Runs | Leetcode 1598 | 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 : Water Bottles | 2 Approaches | Dry Runs | Leetcode 1598 | codestorywithMIK
Company Tags : Google, and some other company Online Assessment problem with slight variation
My solutions on Github(C++ & JAVA) : github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Stack/Easy/Crawler%20Log%20Folder.cpp
Leetcode Link : leetcode.com/problems/crawler-log-folder/description
My DP Concepts Playlist : czcams.com/video/7eLMOE1jnls/video.html
My Graph Concepts Playlist : czcams.com/video/5JGiZnr6B5w/video.html
My Recursion Concepts Playlist : czcams.com/video/pfb1Zduesi8/video.html
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Interview_DS_Algo
Instagram : codestorywithmik
Facebook : people/codestorywithmik/100090524295846/
Twitter : CSwithMIK
Subscribe to my channel : www.youtube.com/@codestorywithMIK
âââŠâââŠââââŠââŠâŠâŠâŠââââ
âââŁâââââŁââŁââŁââŁâââŁââŁ
â âââââââ ââââŁâââââââŁ
âââ©âââ©ââ©ââ©ââ©âââ©ââ©ââ
Summary :
Approach-1: Using Simple Simulation
Description: This approach uses a single integer variable depth to simulate the traversal of folders. The depth variable is incremented when entering a folder and decremented when moving up a directory ("../"), ensuring it doesn't go below zero. The "./" operations are ignored as they do not change the directory.
Time Complexity: O(n), where n is the number of operations. Each operation is processed once.
Space Complexity: O(1), as only a single integer variable is used regardless of the input size.
Approach-2: Using Stack for Simulation
Description: This approach uses a stack to simulate the traversal of folders. Each folder name is pushed onto the stack, and when encountering "../", the stack is popped if it's not empty. The "./" operations are ignored. The size of the stack at the end represents the current depth in the folder structure.
Time Complexity: O(n), where n is the number of operations. Each operation is processed once.
Space Complexity: O(n), as the stack can potentially grow up to the number of operations if no "../" commands are encountered.
Summary
Both approaches efficiently simulate the traversal of the folder structure based on the operations given. The first approach uses a single integer to keep track of the depth, resulting in constant space usage, making it more space-efficient. The second approach uses a stack, which is more intuitive in terms of simulating folder traversal but requires additional space proportional to the number of operations. Both have the same time complexity of O(n).
âš 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
zhlĂ©dnutĂ: 1 705
Video
Average Waiting Time | Simple Simulation | Leetcode 1701 | codestorywithMIK
zhlĂ©dnutĂ 4,7KPĆed 7 hodinami
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 96th Video of our Playlist "Arrays - 1D & 2D : Popular Interview Problems" by codestorywithMIK In this video we will try to solve a good simulation problem : Average Waiting Time | Simple Simulation | Leetcode 1701 | codestorywithMIK I will explain the intuition so easily that you will never forget and start...
Find the Winner of the Circular Game | 3 Approaches | Leetcode 1823 | codestorywithMIK
zhlĂ©dnutĂ 7KPĆed 9 hodinami
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 3rd Video of our Playlist "RECURSION : Popular Interview Problems" by codestorywithMIK In this video we will try to solve a very famous Recursion problem : Find the Winner of the Circular Game | 3 Approaches | Easy Explanations | Leetcode 1823 | codestorywithMIK I will explain the intuition so easily that yo...
Range Update Query | Lazy Propagation | Segment Tree Concepts & Qns | Video 7 | codestorywithMIK
zhlĂ©dnutĂ 705PĆed 9 hodinami
iPad PDF Notes - github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad PDF Notes/Segment Tree - Video - 7.pdf Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 7th video of our playlist "Segment Tree Concepts & Questions". Find the Details below : Video Name : Range Update Query | Lazy Propagation | Segment Tree Concepts & Qns | Video 7 | codestorywithMIK...
Water Bottles | 3 Approaches | Easy Explanations | Leetcode 1518 | codestorywithMIK
zhlĂ©dnutĂ 4,5KPĆed 12 hodinami
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 47th Video of our Playlist "Leetcode Easy : Popular Interview Problems" by codestorywithMIK In this video we will try to solve a good practice problem : Water Bottles | 3 Approaches | Easy Explanations | Leetcode 1518 | codestorywithMIK I will explain the intuition so easily that you will never forget and st...
Pass the Pillow | 2 Approaches | Easy Explanations | Leetcode 2582 | codestorywithMIK
zhlĂ©dnutĂ 3,9KPĆed 14 hodinami
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A 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 ...
Find the Minimum and Maximum Number of Nodes Between Critical Points | 2 Ways | Leetcode 2058
zhlĂ©dnutĂ 4,5KPĆed 17 hodinami
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 26th Video of our Playlist "Linked List : Popular Interview Problems" by codestorywithMIK In this video we will try to solve a good practice problem on Linked List : Find the Minimum and Maximum Number of Nodes Between Critical Points | 2 Ways | Leetcode 2058 | codestorywithMIK I will explain the intuition s...
Merge Nodes in Between Zeros | 2 Approaches | Leap Of Faith | Leetcode 2181 | codestorywithMIK
zhlĂ©dnutĂ 4,1KPĆed 19 hodinami
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 25th Video of our Playlist "Linked List : Popular Interview Problems" by codestorywithMIK In this video we will try to solve a good practice problem on Linked List : Merge Nodes in Between Zeros | 2 Approaches | Recursion Leap Of Faith | Leetcode 2181 | codestorywithMIK I will explain the intuition so easily...
Minimum Difference Between Largest and Smallest Value in Three Moves | 2 Approaches | Leetcode 1509
zhlĂ©dnutĂ 6KPĆed 21 hodinou
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 95th Video of our Playlist "Arrays 1D/2D : Popular Interview Problems" by codestorywithMIK In this video we will try to solve a good Array problem : Minimum Difference Between Largest and Smallest Value in Three Moves | 2 Approaches | Easy Explanations | Leetcode 1509 | codestorywithMIK I will explain the in...
Intersection of Two Arrays II | 2 Approaches | Easy Explanations | Leetcode 350 | codestorywithMIK
zhlĂ©dnutĂ 4,7KPĆed dnem
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 45th Video of our Playlist "Leetcode Easy : Popular Interview Problems" by codestorywithMIK In this video we will try to solve a good practice problem : Intersection of Two Arrays II | 2 Approaches | Easy Explanations | Leetcode 350 | codestorywithMIK I will explain the intuition so easily that you will neve...
Longest Palindromic Subsequence | Using Blue Print | DP On Strings | Leetcode 516 | DP Concepts - 25
zhlĂ©dnutĂ 1,2KPĆed dnem
iPad PDF NOTES - github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad PDF Notes/DP Concepts - Video - 25.pdf Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 25th Video of our Playlist "DP Concepts & Qns" by codestorywithMIK Longest Palindromic Subsequence Recursion Memo & Different Bottom Up - czcams.com/video/M4pfB3G-YQc/video.html This is the Sixth v...
Range Minimum Query | Segment Tree Concepts & Qns | Video 6 | codestorywithMIK
zhlĂ©dnutĂ 1,1KPĆed dnem
iPad PDF Notes - github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad PDF Notes/Segment Tree - Video - 6.pdf Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 6th video of our playlist "Segment Tree Concepts & Questions". Find the Details below : Video Name : Range Minimum Query | Segment Tree Concepts & Qns | Video 6 | codestorywithMIK Video # : 6 đ Unr...
Query Sum II | Segment Tree Concepts & Qns | Video 5 | codestorywithMIK
zhlĂ©dnutĂ 798PĆed dnem
iPad PDF Notes - github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad PDF Notes/Segment Tree - Video - 5.pdf Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 5th video of our playlist "Segment Tree Concepts & Questions". Find the Details below : Video Name : Query Sum II | Segment Tree Concepts & Qns | Video 5 Video # : 5 đ Unraveling Segment Tree : A J...
Longest Palindromic Substring | Recursion Memo | Bottom Up | DP On Strings | Leetcode 5
zhlĂ©dnutĂ 1,2KPĆed dnem
iPad PDF NOTES - github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad PDF Notes/Longest Palindrome String - Leetcode-05-DP Concepts-24.pdf Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 24th Video of our Playlist "DP Concepts & Qns" by codestorywithMIK This is the Sixth video of the "DP On Strings" series in this playlist. In this video we will try to...
All Ancestors of a Node in a Directed Acyclic Graph | 3 Approaches | Leetcode 2192 |codestorywithMIK
zhlĂ©dnutĂ 6KPĆed dnem
Whatsapp Community Link : www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A This is the 51st Video of our Playlist "Graphs : Popular Interview Problems" by codestorywithMIK In this video we will try to solve a good Graph practice problem : All Ancestors of a Node in a Directed Acyclic Graph | 3 Approaches | Thought Process | Leetcode 2192 | codestorywithMIK I will explain the intuition so easil...
Maximum Total Importance of Roads | Thought Process | Leetcode 2285 | codestorywithMIK
zhlĂ©dnutĂ 5KPĆed dnem
Maximum Total Importance of Roads | Thought Process | Leetcode 2285 | codestorywithMIK
Find Center of Star Graph | 2 Simple Approaches | Leetcode 1791 | codestorywithMIK
zhlĂ©dnutĂ 4,2KPĆed dnem
Find Center of Star Graph | 2 Simple Approaches | Leetcode 1791 | codestorywithMIK
Balance a Binary Search Tree | Simple Explanation | Leetcode 1382 | codestorywithMIK
zhlĂ©dnutĂ 6KPĆed 14 dny
Balance a Binary Search Tree | Simple Explanation | Leetcode 1382 | codestorywithMIK
Binary Search Tree to Greater Sum Tree | Brute | Better | Optimal | Leetcode 1038 | codestorywithMIK
zhlĂ©dnutĂ 6KPĆed 14 dny
Binary Search Tree to Greater Sum Tree | Brute | Better | Optimal | Leetcode 1038 | codestorywithMIK
Minimum Number of K Consecutive Bit Flips | 3 Approaches | Detailed | Leetcode 995 | 3191
zhlĂ©dnutĂ 9KPĆed 14 dny
Minimum Number of K Consecutive Bit Flips | 3 Approaches | Detailed | Leetcode 995 | 3191
Segment Tree | Why size is 4*n | With Proof | Video 4
zhlĂ©dnutĂ 1,1KPĆed 14 dny
Segment Tree | Why size is 4*n | With Proof | Video 4
Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit | Leetcode 1438 |Detailed
zhlĂ©dnutĂ 9KPĆed 14 dny
Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit | Leetcode 1438 |Detailed
Count Number of Nice Subarrays | 2 Approaches | Similar Concept | Leetcode 1248 | codestorywithMIK
zhlĂ©dnutĂ 7KPĆed 14 dny
Count Number of Nice Subarrays | 2 Approaches | Similar Concept | Leetcode 1248 | codestorywithMIK
Grumpy Bookstore Owner | Simplest Thought Process | Leetcode 1052 | codestorywithMIK
zhlĂ©dnutĂ 8KPĆed 14 dny
Grumpy Bookstore Owner | Simplest Thought Process | Leetcode 1052 | codestorywithMIK
Magnetic Force Between Two Balls | Simple Thought Process | Leetcode 1552 | codestorywithMIK
zhlĂ©dnutĂ 9KPĆed 14 dny
Magnetic Force Between Two Balls | Simple Thought Process | Leetcode 1552 | codestorywithMIK
Minimum Number of Days to Make m Bouquets | Simple Thought Process| Leetcode 1482 | codestorywithMIK
zhlĂ©dnutĂ 8KPĆed 21 dnem
Minimum Number of Days to Make m Bouquets | Simple Thought Process| Leetcode 1482 | codestorywithMIK
Segment Tree | Range Sum Query | Story To Code | Video 3
zhlĂ©dnutĂ 1,7KPĆed 21 dnem
Segment Tree | Range Sum Query | Story To Code | Video 3
Most Profit Assigning Work | Multiple Approaches | With Intuition | Leetcode 826 | codestorywithMIK
zhlĂ©dnutĂ 8KPĆed 21 dnem
Most Profit Assigning Work | Multiple Approaches | With Intuition | Leetcode 826 | codestorywithMIK
Segment Tree | Update Query | Story To Code | Video 2
zhlĂ©dnutĂ 2,1KPĆed 21 dnem
Segment Tree | Update Query | Story To Code | Video 2
Segment Tree | Introduction | Basics | Build Segment Tree | Video 1 | codestorywithMIK
zhlĂ©dnutĂ 5KPĆed 21 dnem
Segment Tree | Introduction | Basics | Build Segment Tree | Video 1 | codestorywithMIK
Can some body tell me whats wrong in this code vector<int> ans; ans.push_back(0); if(n==0){ return ans; } for(int i=1; i<= n; i++){ int count =0; for(int j=0; j<32; j++){ if((i & (1<<j))==1){ count++; } } ans.push_back(count); }return ans;
Thank you bhaiya!
class Solution { public int minOperations(String[] logs) { int level=1; for(String op : logs){ if(op.equals("./")){ continue; } else if(op.equals("../")){ if(level != 1){ level--; } } else{ level++; } } return level-1; } } a good simple problem to build confidence..
Super and easy Explaination! perfect! Thank you...
Thankyou bhaiya!
thank u sir
|| Java Solutions || // 1. With Stack class Solution { public int minOperations(String[] logs) { Stack<String> st = new Stack<String>(); for(int i=0; i<logs.length; i++){ if(logs[i].equals("../")){ if(!st.isEmpty()){ st.pop(); } }else if(logs[i].equals("./")){ continue; }else{ st.push(logs[i]); } } return st.size(); } } // 2. Without Stack class Solution { public int minOperations(String[] logs) { int steps=0; for(int i=0; i<logs.length; i++){ if(logs[i].equals("./")){ continue; }else if(logs[i].equals("../")){ steps = Math.max(0, --steps); }else{ steps++; } } return steps; } }
sir os, dbms jaise core subs ke lie guide kardo ya resources bata do kaise padhe for interviews?
for(string &log:logs) ka faeda kya hai & na lagae to kya farak padega ???
Approach - Initiate the count with zero. - Iterate through the whole logs and each time when "../" appears if count >0 then there will be decreament in count. - When "./" appears then leave the count as it is. - when "x/" appears increase the count by 1. - Finally when getting out of the loop if count<0 then return 0 else return count. class Solution { public: int minOperations(vector<string>& logs) { int n = logs.size(); int cnt=0; for(int i=0;i<n;i++){ if(logs[i]=="../"){ if(cnt>0) { cnt--; } } else if(logs[i]=="./")continue; else{ cnt++; } } if(cnt<0) return 0; return cnt; } };
500 days đ„
500days man legendary
Mai apko kafi phle se follow kr rha and itta detail me dsa ke vids shyd hi koi bnata hai . Thanks bhaiya and waiting for 57k
your explanation is fabulous. your are so consistent, bhaiya can you tell me how to stay consistent.
We can also store the LCS while the table is in making when : if(s1[i-1] == s2[j-1]){ lcs += s1[i-1]; dp[i][j] = 1 + dp[i-1][j-1]; } Right?
class Solution { public: double averageWaitingTime(vector<vector<int>>& customers) { int n = customers.size(); double wait=0; double time = customers[0][0]; for(auto &it: customers){ if(time>=it[0]){ time+= it[1]; int x =time-it[0]; wait+=x; } else{ time =it[0]; time+= it[1]; int x =time-it[0]; wait+=x; } } return (wait/n); } };
Maximum Product of Word Lengths | LeetCode 318 pe vdo bna do sir
Thanks a lot
//vector<int> getNSL(vector<int>& arr, int n) , bhaiya aapne yaha NSL likh rakha hai or aap for loop se travel kr rhe right side //for(int i = 0; i<n; i++)
Bhai aise hi roz upload karte raho mai aapko dekh kar proper consistent leetcode chalu kar diya hai
Thanks a lot bhaiya â€â€
You make it simple sir đâ€ïžand easyâ€ïž
class Solution { public: int minOperations(vector<string>& logs) { stack<string> st; for(auto s : logs){ string str = s.substr(0,s.size()-1); cout<<str<<" "; if(!st.empty() && str == "..") st.pop(); else if(str == ".") continue; else if(str != "..") st.push(str); } return st.size(); } };â€â€
Bro how u uploaded this video at 7 or 6 am !! Like when did u even recorded and edited it
Jaldi uth jata h bhai humara đź
After watching ur trie video I did it myself thank u for everything
So happy to hear that â€ïž Keep it up
@@codestorywithMIK yes sir trying to give my best for the coming OAs
Stack is useful if asked to trace the actual path back (see Leetcode editorial)
Bhaiya Thanks for this video tooooo........can you make a video on Leetcode 306. Additive Number
It was easy đ
Anyone who wants to practise dsa like listening a story this is the guy u should follow :)
Good morning. I did it using stack đ
Hi priyanshi I know you đ
Good morning bhaiya đ
keep doing it ....<3
Good morning sir, just submitted my solution and got notification of your video â€
God level of explanation by the DSA god MIK
i have a doubt...can i even solve this on my own in the future...i really had this doubt from my past 1.5 year coding experience...đđ
You're Really helping the CP community. Big Kudos from my side!! ..... Please make this kind of Video. you motivated us to fight for our Goal
good
sir which writing software do you use??
bro when will i think like u
my approach class Solution { public double averageWaitingTime(int[][] arr) { int n=arr.length; double sum=arr[0][1]; int p=arr[0][0]+arr[0][1]; for(int i=1;i<n;i++){ if(arr[i][0]<p){ p+=arr[i][1]; sum+=(p-arr[i][0]); } else{ sum+=arr[i][1]; p=arr[i][0]+arr[i][1]; } } return sum/n; } }
I spent one hour and still ,I am here!
you r a gem sir
Respected MIK Sir, I solved this problem by myself. Thanks for building my logical skills. đđ Here's my Java code: public double averageWaitingTime(int[][] customers) { int n = customers.length; double sum = 0; double previousDelay = 0; for (int[] customer: customers) { double customerArrivalTime = customer[0]; double cookingDuration = customer[1]; double cookingStartTime = Math.max(previousDelay, customerArrivalTime); double cookingEndTime = cookingStartTime + cookingDuration; double waitingTime = cookingEndTime - customerArrivalTime; previousDelay = cookingEndTime; sum += waitingTime; } return sum / n; }
Bhaiya yr aap kamaal ho daily morning uthta hu toh dekhta hu ki aapne leetcode ka potd solve krke daal diye toh esse khaafi motivation milti h ki ha bhaiya daale toh krna toh bnta h thnq bhaiya chizon ko etna aasan bnane ke liye
I made the exact same logic and on my own. Though this is easy one, but I am glad that the thought process matched.
Best Explaination for LFUđ
Based on FCFS algorithm which we studied in operating system
aaj ka question khud se kar liya... pehle mai itne bade question padh ke ghabra jaata tha.. your videos help .. bas ab series waali playlist start karni ... starting with recurison... my code intially failed beacause maine total time etc int mai le liya tha..kuch range ka issue tha I think class Solution { public double averageWaitingTime(int[][] customers) { int n = customers.length; double total_time = 0; int arrival_time = 0; int prepare_time = 0; double avg_time= 0; for(int[] x : customers){ arrival_time = x[0]; prepare_time = x[1]; if(arrival_time > total_time){ total_time += (arrival_time - total_time); } total_time += prepare_time; double waiting_time = total_time - arrival_time; avg_time += waiting_time; } return avg_time / n; } }
Solved this one without video because of your daily videos đ«Ąđ§âđ». || Easy Java Solution || class Solution { public double averageWaitingTime(int[][] customers) { int totWaitTime = customers[0][0] + customers[0][1]; double waitSum = customers[0][1]; for(int i=1; i<customers.length; i++){ int[] customer = customers[i]; if(customer[0] <= totWaitTime){ totWaitTime += customer[1]; waitSum += (totWaitTime - customer[0]); } else{ totWaitTime = customer[0] + customer[1]; waitSum += customer[1]; } } return waitSum/customers.length; } }
Hello Could you please make video solution for 2407. Longest Increasing Subsequence II. This playlist is amazingđ„