Counting Elements
https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/528/week-1/3289/
Given an integer array arr
, count element x
such that x + 1
is also in arr
.
If there're duplicates in arr
, count them seperately.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= arr.length <= 1000
0 <= arr[i] <= 1000
对给定数组要求元素值比它大一的元素也存在于数组中,统计满足条件的元素个数。检查是否存在用hash set。
Last updated
Was this helpful?