LeetCode 136 | Single Number | Solution Explained (Java + Whiteboard)

preview_player
Показать описание
Given a non-empty array of integers, every element appears twice except for one. Find that single one.

Note:

Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

Example 1:

Input: [2,2,1]
Output: 1

Running Time: O(N)
Space Complexity: O(1)

Рекомендации по теме