最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

Leetcode 2057. Smallest Index With Equal Value

2023-01-19 12:30 作者:您是打尖兒還是住店呢  | 我要投稿

Given a?0-indexed?integer array?nums, return?the?smallest?index?i?of?nums?such that?i mod 10 == nums[i], or?-1?if such index does not exist.

x mod y?denotes the?remainder?when?x?is divided by?y.

?

Example 1:

Input: nums = [0,1,2]Output: 0Explanation: i=0: 0 mod 10 = 0 == nums[0]. i=1: 1 mod 10 = 1 == nums[1]. i=2: 2 mod 10 = 2 == nums[2]. All indices have i mod 10 == nums[i], so we return the smallest index 0.

Example 2:

Input: nums = [4,3,2,1]Output: 2Explanation: i=0: 0 mod 10 = 0 != nums[0]. i=1: 1 mod 10 = 1 != nums[1]. i=2: 2 mod 10 = 2 == nums[2]. i=3: 3 mod 10 = 3 != nums[3]. 2 is the only index which has i mod 10 == nums[i].

Example 3:

Input: nums = [1,2,3,4,5,6,7,8,9,0]Output: -1Explanation: No index satisfies i mod 10 == nums[i].

用優(yōu)先隊(duì)列的話,就不需要一次排序了。會(huì)更方便的。

Easy題目;

Runtime2 ms

Beats

28.70%

Memory42.6 MB

Beats

48.94%

Click to check the distribution chart


Leetcode 2057. Smallest Index With Equal Value的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
凌海市| 平果县| 洛扎县| 石台县| 麟游县| 宁南县| 忻城县| 济宁市| 天峨县| 云霄县| 长垣县| 桦甸市| 高邮市| 石城县| 岑溪市| 连云港市| 永丰县| 奉节县| 龙海市| 周宁县| 朝阳县| 深圳市| 隆回县| 中牟县| 耒阳市| 新乡市| 博白县| 盈江县| 泰和县| 同江市| 江孜县| 会理县| 北京市| 伊通| 大田县| 华阴市| 桑植县| 衡水市| 仙居县| 巴彦县| 余庆县|