LeetCode 217: Contains duplicate ⁇ Suppose you have a list of numbers, and you want to know if any number appears more than once. It’s like making sure everyone in class has a unique roll number! Approach 1: Set - Go through each number. - If it’s not in your set, add it. - If you ever see a number already in your set, you’ve got a duplicate! Approach 2: Hash Table (Counter) - Use a Counter to count how often each number appears in the list. - If any number appears more than once, return True (there’s a duplicate). Complexity: - Time Complexity: O(n) — One pass through all numbers. - Space Complexity: O(n) — Storing seen numbers or counts. Both approaches are fast and effective for catching duplicates quickly! Let’s check our numbers and make sure everyone’s unique! Check out the problem here: https://lnkd.in/g-JgRTEn Keep going, keep revising, and keep building confidence! 💪🔥 #DSA #Coding #ProblemSolving #Learning

To view or add a comment, sign in

Explore content categories