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

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

LeetCode 2283. Check if Number Has Equal Digit Count and Digit V

2023-03-21 15:24 作者:您是打尖兒還是住店呢  | 我要投稿

You are given a?0-indexed?string?num?of length?n?consisting of digits.

Return?true?if for?every?index?i?in the range?0 <= i < n, the digit?i?occurs?num[i]?times in?num, otherwise return?false.

?

Example 1:

Input: num = "1210"

Output: true

Explanation:num[0] = '1'. The digit 0 occurs once in num. num[1] = '2'. The digit 1 occurs twice in num. num[2] = '1'. The digit 2 occurs once in num. num[3] = '0'. The digit 3 occurs zero times in num. The condition holds true for every index in "1210", so return true.

Example 2:

Input: num = "030"

Output: false

Explanation:num[0] = '0'. The digit 0 should occur zero times, but actually occurs twice in num. num[1] = '3'. The digit 1 should occur three times, but actually occurs zero times in num. num[2] = '0'. The digit 2 occurs zero times in num. The indices 0 and 1 both violate the condition, so return false.

?

Constraints:

  • n == num.length

  • 1 <= n <= 10

  • num?consists of digits.

  • 把字符串中的每個數(shù)字都放到map中,然后遍歷map中的數(shù)字跟值去判斷是否是一樣的,如果不一樣則返回flag。

  • 簡單的題目,但是通過的空間跟時間復(fù)雜度都是不好的。。

Runtime:?13 ms, faster than?6.62%?of?Java?online submissions for?Check if Number Has Equal Digit Count and Digit Value.

Memory Usage:?42.7 MB, less than?6.74%?of?Java?online submissions for?Check if Number Has Equal Digit Count and Digit Value.


LeetCode 2283. Check if Number Has Equal Digit Count and Digit V的評論 (共 條)

分享到微博請遵守國家法律
勃利县| 瓦房店市| 高邑县| 龙南县| 肇源县| 山丹县| 马边| 遂宁市| 汕头市| 蒲江县| 平潭县| 荃湾区| 凤台县| 阜康市| 二连浩特市| 石城县| 奎屯市| 常州市| 苗栗市| 阿克陶县| 桓台县| 鞍山市| 军事| 麦盖提县| 当涂县| 蕉岭县| 宣化县| 略阳县| 佛教| 台安县| 兴国县| 贵阳市| 黄山市| 肃北| 临湘市| 平果县| 新兴县| 龙门县| 三台县| 邻水| 西畴县|