136. Single Number
Tags:
Easy
Skills:
Bitwise
June 24, 2025
04:32 AM
No headings found
Loading content...
Related Posts
Leetcode
No headings found
Related Posts
Leetcode
Problem
Bài toán yêu cầu tìm phần tử duy nhất xuất hiện một lần trong mảng số nguyên, trong khi các phần tử khác đều xuất hiện đúng hai lần.
Approach - XOR
Solution
1function singleNumber(nums: number[]): number {
2 let res = 0
3 for(const num of nums) res = res ^ num
4 return res
5};