五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

LeetCode 2224. Minimum Number of Operations to Convert Time

2023-05-18 13:11 作者:您是打尖兒還是住店呢  | 我要投稿

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.

?

Example 1:

Input: current = "02:30", correct = "04:35"

Output: 3

Explanation:

We can convert current to correct in 3 operations as follows: - Add 60 minutes to current. current becomes "03:30". - Add 60 minutes to current. current becomes "04:30". - Add 5 minutes to current. current becomes "04:35". It can be proven that it is not possible to convert current to correct in fewer than 3 operations.

Example 2:

Input: current = "11:00", correct = "11:01"

Output: 1

Explanation: We only have to add one minute to current, so the minimum number of operations needed is 1.

?

Constraints:

  • current?and?correct?are in the format?"HH:MM"

  • current <= correct

主要是寫2個函數(shù),一個是將小時轉(zhuǎn)換成分鐘,這樣所有的數(shù)據(jù)都是用分鐘去判斷,

剩下就是判斷調(diào)整的次數(shù),用while循環(huán)即可;(我沒看完題目,這里面current是一定小于correct的,但是代碼里面是加了一層判斷的)

下面是代碼:

Runtime:?1 ms, faster than?94.12%?of?Java?online submissions for?Minimum Number of Operations to Convert Time.

Memory Usage:?40.9 MB, less than?61.03%?of?Java?online submissions for?Minimum Number of Operations to Convert Time.


LeetCode 2224. Minimum Number of Operations to Convert Time的評論 (共 條)

分享到微博請遵守國家法律
嵊州市| 辽阳县| 吉木乃县| 浮山县| 涿州市| 天峻县| 宕昌县| 河北区| 屏东市| 黔西县| 五台县| 宁安市| 灯塔市| 新源县| 佛坪县| 新沂市| 武邑县| 拉孜县| 体育| 西乌珠穆沁旗| 邹平县| 沐川县| 克山县| 维西| 新乐市| 石嘴山市| 蓬溪县| 林周县| 如皋市| 新余市| 上杭县| 鄂州市| 闽清县| 宜章县| 文成县| 商南县| 榆林市| 诸城市| 当雄县| 鄯善县| 三都|