← Back to LeetCode Notes

3014. Minimum Number of Pushes to Type Word I

easy · math · string · greedy · solved 2026.07.30 · 10 sec read

View on LeetCode ↗
C++
class Solution {public:    int minimumPushes(string word) {        return min(static_cast<int>(word.length()), 8) +               min(clamp(static_cast<int>(word.length()) - 8, 0, 99999) *                       2,                   16) +               min(clamp(static_cast<int>(word.length()) - 16, 0, 99999) *                       3,                   24) +               min(clamp(static_cast<int>(word.length()) - 24, 0, 99999) *                       4,                   32);    }};

was just simple math stuff, could have done better way with blocking but i just got this done.