C++  ✅✅[ 0 ms Beats 100.00% ] 👍🏻 Easy Intuitive
IntuitionWe need to determine the minimum cost required to enter a given time on a digital clock by evaluating all possible valid representations of the time.Ap
### Intuition  
We need to determine the minimum cost required to enter a given time on a digital clock by evaluating all possible valid representations of the time.  

### Approach  
1. **Understanding the Time Format:**  
   - Each minute consists of 60 seconds.  
   - The clock can display up to **99 seconds** instead of transitioning to the next minute.  

2. **Generating Possible Representations:**  
   - Compute the standard minute-second representation:  
     
    **minutes = target / 60
     **
    **seconds = target % 60**
     
   - Consider alternative representations by adjusting the minute count downwards while ensuring the seconds value remains **≤ 99**.  
   - Example:  
     - `10:00` can also be represented as `09:60`  
     - `09:30` can be written as `08:90` (both equivalent to 570 seconds).  

3. **Calculating the Input Effort (Score):**  
   - Start from `startAt` and track the previous digit.  
   - Increment the effort count only when transitioning to a different digit.  

4. **Handling Edge Cases:**  
   - Ensure the final displayed time has exactly **four digits** by removing any leading zeros.  

By evaluating all valid representations and calculating their input effort, we determine the one requiring the least cost.


# Code
```cpp []
class Solution {
public:
    int fun(int startAt, int moveCost, int pushCost,int min,int sec){
        vector<int>v;
        string str=to_string(min);
        for(auto c:str)
        {
            v.push_back(c-'0');
        }
        str=to_string(sec);
        if(str.size()==1)v.push_back(0);
        for(auto c:str)
        {
            v.push_back(c-'0');
        }
        int i=0;
        while(v[i]==0){
            i++;
        }
        vector<int>vv;
        for(int j=i;j<v.size();j++)vv.push_back(v[j]);
        v=vv;
        int prev=startAt;
        if(v.size()>4)return INT_MAX;
        int cnt=0;
        for(int i=0;i<v.size();i++){
            if(v[i]==prev){
                    cnt+=pushCost;
                }
                else {
                    cnt+=pushCost;
                    cnt+=moveCost;
                    prev=v[i];
                }
        }
        return cnt;
    }
    int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {
        
       
        int ans=INT_MAX;
        int n=targetSeconds;
        int minutes=n/60;
        int sec=n-(minutes*60);
         vector<int>v;
        int cost=fun(startAt,moveCost,pushCost,minutes,sec);
        ans=min(ans,cost);
        while(minutes--){
            int sec=n-(minutes*60);
            if(sec<=99){
                 int cost=fun(startAt,moveCost,pushCost,minutes,sec);
        ans=min(ans,cost);
            }
            else break;

        }
        return ans;
        
        return 0;
    }
};
```
['Simulation', 'C++']