In this video, I solve LeetCode Problem 217 - Contains Duplicate using the Sorting method.
🔍 What you'll learn:
Intuition behind using sorting to detect duplicates
Step-by-step explanation of the approach
How adjacent comparison works after sorting
Time and space complexity analysis
💡 By sorting the array first, duplicates (if any) will appear next to each other—making them easy to detect in a single pass.
⏱ Time Complexity: O(n log n)
📦 Space Complexity: O(1) (depends on sorting algorithm)
📚 Problem Link:
https://leetcode.com/problems/contains-duplicate/
🚀 Next: More optimized solution using HashSet (O(n))
#leetcode #dsa #sorting #algorithms #coding #programming #interviewprep