🚀 Day 2 of #100DaysOfCode Solved Contains Duplicate on LeetCode ✅ 🧠 Key takeaway: Using a HashSet helps quickly check if any element appears more than once by leveraging constant-time lookups. ⚙️ Approach: 🔹Traverse the array 🔹Add elements to a set 🔹If an element already exists → duplicate found ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) #100DaysOfCode #LeetCode #DSA #Java #HashSet #ProblemSolving #LearningInPublic
LeetCode: Solved Contains Duplicate with HashSet
More Relevant Posts
-
Day 36/100 – LeetCode Challenge 🚀 Problem: 3Sum Closest Approach: Sorted the array Fixed one element and applied the two-pointer technique Tracked the closest sum by comparing absolute differences Returned immediately if an exact match was found Time Complexity: O(n²) Space Complexity: O(1) Key takeaway: Many optimization problems are variations of classic patterns. Understanding 3Sum deeply makes solving 3Sum Closest straightforward. #LeetCode #100DaysOfCode #DSA #Java #TwoPointers #ProblemSolving #InterviewPrep
To view or add a comment, sign in
-
-
🚀 Day 14 of #GeekStreak60 Today’s Problem: Find the Closest Pair from Two Sorted Arrays ✅ Solved using the Two Pointer approach since both arrays were sorted. Optimized from O(n × m) to O(n + m) by smart pointer movement. 📌 Key Takeaway: Whenever arrays are sorted, think Two Pointers first. @GeeksforGeeks @NPCI #GeekStreak60 #DSA #ProblemSolving #Java #CodingChallenge #NPCI
To view or add a comment, sign in
-
-
🚀 Day 14 of #GeekStreak60 Today’s Problem: Find the Closest Pair from Two Sorted Arrays ✅ Solved using the Two Pointer approach since both arrays were sorted. Optimized from O(n × m) to O(n + m) by smart pointer movement. 📌 Key Takeaway: Whenever arrays are sorted, think Two Pointers first. @GeeksforGeeks @NPCI #GeekStreak60 #DSA #ProblemSolving #Java #CodingChallenge #NPCI
To view or add a comment, sign in
-
-
Day 35/100 – LeetCode Challenge 🚀 Problem: 3Sum Approach: Sorted the array Fixed one element and used two pointers for the remaining two Skipped duplicates to ensure unique triplets Used early stopping when the current number became positive Time Complexity: O(n²) Space Complexity: O(1) Key takeaway: Many 3-element sum problems reduce to sorting + two-pointer pattern. #LeetCode #100DaysOfCode #DSA #Java #TwoPointers #ProblemSolving #InterviewPrep
To view or add a comment, sign in
-
-
Day: 45/365 📌 LeetCode POTD: Special Binary String Hard Key takeaways/Learnings from this problem: 1. This one teaches that recognizing a balanced structure (like valid parentheses) inside a binary string is the real trick. 2. Big takeaway: recursion + sorting substrings smartly can turn a complex greedy-looking problem into something surprisingly elegant. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
-
Day 21 - Binary Search Key Idea: Implemented an iterative binary search to locate the target in a sorted array. Reduced the search interval by half in every iteration to achieve logarithmic runtime. Time Complexity: O(log n) #Day21 #LeetCode #Java #BinarySearch #DSA #Algorithms
To view or add a comment, sign in
-
-
Day: 32/365 📌 LeetCode POTD: Minimum Deletions to make string balanced Medium Key takeaways/Learnings from this problem: 1. Using a stack makes the imbalance obvious—you directly see where a b is messing up the order before an a. 2. Big takeaway: sometimes simulating the process cleanly is easier than mathy DP, and still gives an optimal result. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
Day 29/100 – LeetCode Challenge 🚀 Problem: Same Tree Approach: Used recursive traversal Compared corresponding nodes of both trees Checked: both nodes null → identical one null → not identical values mismatch → not identical recursively compared left and right subtrees Time Complexity: O(n) Space Complexity: O(h) Key takeaway: Many tree comparison problems reduce to simultaneous traversal of both trees. #LeetCode #100DaysOfCode #DSA #Java #BinaryTree #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 13 of #100DaysOfCode Solved Remove Linked List Elements on LeetCode 🔗 🧠 Key insight: While traversing a linked list, careful pointer updates are needed—especially when the head node itself matches the value to be removed. ⚙️ Approach: 🔹Handle cases where the head contains the target value 🔹Traverse the list using a pointer 🔹Skip nodes whose value matches the given target by adjusting next pointers ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) #100DaysOfCode #LeetCode #DSA #LinkedList #Java #ProblemSolving #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
-
Day 26/100 – LeetCode Challenge 🚀 Problem: Remove Duplicates from Sorted List Approach: Traversed the linked list using a pointer Compared each node with its next node Skipped the next node whenever duplicate values were found Time Complexity: O(n) Space Complexity: O(1) Key takeaway: When a linked list is sorted, duplicate removal becomes a simple one-pass pointer manipulation problem. #LeetCode #100DaysOfCode #DSA #Java #LinkedList #ProblemSolving
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development