Solved LeetCode 137: Single Number II with HashMap in Java

🎯 Day 82 of #100DaysOfCode – LeetCode 137: Single Number II Today’s challenge was about identifying the unique number in an array where every element appears three times except for one. 🧩 Problem Statement: Given an integer array nums, where every element appears exactly three times except for one, find that single element that appears only once. Example: Input: [2,2,3,2] Output: 3 💭 Approach 1: Using HashMap At first, I solved this using a HashMap to count the frequency of each number. Traverse the array and store each element’s occurrence. Return the element whose count equals 1. 🕒 Time Complexity: O(n) 💾 Space Complexity: O(n) 🚀 Key Takeaway: Sometimes, the best way to optimize is not by adding more data structures, but by understanding how data behaves at the bit level. #100DaysOfCode #Day82 #LeetCode #Java #ProblemSolving #DSA #CodingJourney #BitManipulation #KeepLearning

  • graphical user interface, text, application, email

To view or add a comment, sign in

Explore content categories