Minimum Number of Operations to Convert Time

RedAurtherRedAurther
1 min read

๐Ÿง  Problem

You are given two strings current and correct representing two 24-hour times. 24-hour times are formatted as "HH:MM", where HH is between 00 and 23, and MM is between 00 and 59. The earliest 24-hour time is 00:00, and the latest is 23:59. In one operation you can increase the time current by 1, 5, 15, or 60 minutes. You can perform this operation any number of times. Return the minimum number of operations needed to convert current to correct.


๐Ÿท๏ธ Tags

string, greedy


๐Ÿ“Š Difficulty

Easy

โœ… Success Rate: 61.8%
๐Ÿ“ฅ Submissions: 27,654
๐Ÿ“ˆ Accepted: 17,096


โค๏ธ Reactions

๐Ÿ‘ Likes: 133
๐Ÿ‘Ž Dislikes: 17


๐Ÿ’ก Hints

Convert the times to minutes. Use the operation with the biggest value possible at each step.


๐Ÿ” Similar Questions

  • Coin Change

Leetcode Link : Minimum Number of Operations to Convert Time

0
Subscribe to my newsletter

Read articles from RedAurther directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

RedAurther
RedAurther