2162. Minimum Cost to Set Cooking Time
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int minCostSetTime(int initialPosition, int costToMove, int costToPush, int totalSeconds) {
        vector<string> timeCombinations;
        int minutesPart = totalSeconds / 60;
        int secondsPart = totalSeconds % 60;

        if (minutesPart < 100) {
            timeCombinations.push_back(to_string(minutesPart * 100 + secondsPart));
        }
        if (secondsPart < 40 && minutesPart > 0) {
            timeCombinations.push_back(to_string((minutesPart - 1) * 100 + secondsPart + 60));
        }

        int minimumExpense = INT_MAX;
        for (const string& time : timeCombinations) {
            int totalExpense = time.length() * costToPush;
            char currentPosition = '0' + initialPosition;

            for (char digit : time) {
                if (digit != currentPosition) {
                    totalExpense += costToMove;
                }
                currentPosition = digit;
            }
            minimumExpense = min(minimumExpense, totalExpense);
        }
        return minimumExpense;
    }
};
```
['C++']