• Skip to primary navigation
  • Skip to content
  • Skip to footer
zhicheng xie's demo blog
  • Quick-Start Guide

    Your Name

    I am an amazing person.

    • Somewhere

    Calculate Money in Leetcode Bank

    less than 1 minute read

    <-E 1716> Calculate Money in Leetcode Bank

    class Solution {
    public:
        int totalMoney(int n) {
            int total{0};
            int week{1}, accrue{1};
            
            for(int i{1}; i <= n; i++){
                if(i - 1 == 7 * week){
                    ++week;
                    accrue = week;
                }
                
                total += accrue;
                accrue++;
            } 
            return total;       
        }
    };
    

    Tags: Algorithms, C++, Leetcode

    Updated: April 8, 2022

    Share on

    Twitter Facebook LinkedIn
    Previous Next

    You may also enjoy

    Decode Ways

    less than 1 minute read

    <-M 91> Decode Ways

    Word Break

    less than 1 minute read

    <-H 139> Word Break

    Distinct Subsequences

    less than 1 minute read

    <-H 115> Distinct Subsequences

    Edit Distance

    less than 1 minute read

    <-H 72> Edit Distance

    • Follow:
    • Feed
    © 2023 zhicheng xie's blog. Powered by Jekyll & Minimal Mistakes.