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

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

Leetcode2525. Categorize Box According to Criteria

2023-01-14 16:54 作者:您是打尖兒還是住店呢  | 我要投稿

You are given a?0-indexed?integer array?forts?of length?n?representing the positions of several forts.?forts[i]?can be?-1,?0, or?1?where:

  • -1?represents there is?no fort?at the?ith?position.

  • 0?indicates there is an?enemy?fort at the?ith?position.

  • 1?indicates the fort at the?ith?the position is under your command.

Now you have decided to move your army from one of your forts at position?i?to an empty position?j?such that:

  • 0 <= i, j <= n - 1

  • The army travels over enemy forts?only. Formally, for all?k?where?min(i,j) < k < max(i,j),?forts[k] == 0.

While moving the army, all the enemy forts that come in the way are?captured.

Return?the?maximum?number of enemy forts that can be captured. In case it is?impossible?to move your army, or you do not have any fort under your command, return?0.

?

Example 1:

Input: forts = [1,0,0,-1,0,0,0,0,1]Output: 4Explanation:- Moving the army from position 0 to position 3 captures 2 enemy forts, at 1 and 2. - Moving the army from position 8 to position 3 captures 4 enemy forts. Since 4 is the maximum number of enemy forts that can be captured, we return 4.

Example 2:

Input: forts = [0,0,1,-1]Output: 0Explanation: Since no enemy fort can be captured, 0 is returned.

?

Constraints:

  • 1 <= forts.length <= 1000

  • -1 <= forts[i] <= 1

Easy題目,不贅述;

Runtime0 ms

Beats

100%

Memory39.7 MB

Beats

22.69%


Leetcode2525. Categorize Box According to Criteria的評論 (共 條)

分享到微博請遵守國家法律
博野县| 海盐县| 汉阴县| 称多县| 陆良县| 辽阳县| 凌源市| 汾西县| 勃利县| 安乡县| 寻甸| 乌鲁木齐市| 安宁市| 乐昌市| 舟山市| 普宁市| 永康市| 济南市| 柘城县| 土默特左旗| 汕头市| 兰西县| 郁南县| 本溪市| 东方市| 四子王旗| 贞丰县| 仙居县| 汉川市| 民和| 雷州市| 大宁县| 启东市| 娄烦县| 蕲春县| 乌恰县| 东阳市| 铜陵市| 万荣县| 安远县| 客服|