Calculate Money in Leetcode Bank | 2 Approaches | O(n) | O(1) | Leetcode 1716
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 18th Video of our Sliding Window Playlist.
In this video we will try to solve an easy but good Maths problem - Calculate Money in Leetcode Bank (Leetcode 1716).
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 : Calculate Money in Leetcode Bank
Company Tags : will soon update
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Mathematical/Calculate%20Money%20in%20Leetcode%20Bank.cpp
Leetcode Link : https://leetcode.com/problems/calculate-money-in-leetcode-bank/
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Approach 1 Summary :
The approach involves calculating the arithmetic sum of the total money obtained from complete weeks and then adding the remaining days' earnings for the final week. The earnings for each day in the final week start from 1 on Monday and increase by the number of completed weeks. The method takes an integer parameter n representing the number of weeks for which the total money is to be calculated and returns the result.
Approach 2 Summary :
The approach involves iterating through each week, starting from Monday, and adding the earnings for each day (starting from 1) up to a maximum of 7 days or the remaining days if less than a week. The method uses a while loop to handle the total number of weeks and adjusts the earnings for each day accordingly. The method returns the overall total amount of money earned.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ 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