We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Lonely Integer
- Discussions
Lonely Integer
Lonely Integer
Sort by
recency
|
450 Discussions
|
Please Login in order to post a comment
from collections import Counter
def lonelyinteger(a): count = Counter(a) for key,val in count.items(): if val == 1: return key
include
include // For std::accumulate
include
int lonelyinteger(const std::vector& nums) { return std::accumulate(nums.begin(), nums.end(), 0, std::bit_xor()); }
int main() { std::vector nums = {1, 1, 2, 2, 3}; // Example input std::cout << lonelyinteger(nums) << std::endl; return 0; }
Kotlin Solution
C# solution