Created
January 2, 2026 07:42
-
-
Save rtsoy/f00629d1f9cd6181e83129e97767892e to your computer and use it in GitHub Desktop.
136. Single Number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://leetcode.com/problems/single-number/ | |
| // | |
| // Time: O(n) | |
| // Space: O(1) | |
| // | |
| // n - number of elements in array | |
| // .................... // | |
| func singleNumber(nums []int) int { | |
| res := 0 | |
| for _, num := range nums { | |
| res ^= num | |
| } | |
| return res | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment