My LeetCode grinding. Trying to do a problem a day.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

problem.txt 644B

123456789101112131415161718192021222324252627282930313233
  1. Given an integer array arr, count element x such that x + 1 is also in arr.
  2. If there're duplicates in arr, count them seperately.
  3. Example 1:
  4. Input: arr = [1,2,3]
  5. Output: 2
  6. Explanation: 1 and 2 are counted cause 2 and 3 are in arr.
  7. Example 2:
  8. Input: arr = [1,1,3,3,5,5,7,7]
  9. Output: 0
  10. Explanation: No numbers are counted, cause there's no 2, 4, 6, or 8 in arr.
  11. Example 3:
  12. Input: arr = [1,3,2,3,5,0]
  13. Output: 3
  14. Explanation: 0, 1 and 2 are counted cause 1, 2 and 3 are in arr.
  15. Example 4:
  16. Input: arr = [1,1,2,2]
  17. Output: 2
  18. Explanation: Two 1s are counted cause 2 is in arr.
  19. Constraints:
  20. 1 <= arr.length <= 1000
  21. 0 <= arr[i] <= 1000