> Problem: Single Number > Platform: LeetCode > Concept: Bit Manipulation (XOR) Solved this problem using the XOR operation, where duplicate numbers cancel each other and the unique number remains. > Key Idea: a ^ a = 0 a ^ 0 = a XOR all elements to get the single occurring number > Time Complexity: O(n) > Space Complexity: O(1) #DSAPrep #Algorithms #Python #BitManipulation #ProblemSolving #CodingJourney
XOR to Find Single Number
More Relevant Posts
-
Remove Nth From End: Two-Pointer Gap for One-Pass Deletion Finding nth from end typically needs list length calculation first (two passes). Optimization: maintain n-node gap between pointers. Advance right n steps, then move both together — when right hits end, left is exactly one before target. One pass only. Fixed-Gap Pattern: Two pointers with fixed separation enable relative positioning without counting. Dummy node handles head deletion edge case. This gap technique appears in cycle detection, palindrome validation. Time: O(n) single pass | Space: O(1) #TwoPointers #FixedGap #LinkedList #OnePassAlgorithm #Python #AlgorithmDesign #SoftwareEngineering
To view or add a comment, sign in
-
-
Contains Nearby Duplicate: Fixed-Distance Window with HashSet Checking all pairs within k distance is O(n×k). Sliding window optimizes to O(n) — maintain window of at most k elements. When distance exceeds k, remove leftmost element. Each element enters/exits set exactly once. Distance Constraint: Maintaining window size ≤ k ensures any duplicate found satisfies proximity requirement. This distance-based window appears in rate limiting, time-series analytics, proximity problems. Time: O(n) | Space: O(min(n, k)) #SlidingWindow #HashSet #DistanceConstraint #DuplicateDetection #Python #AlgorithmOptimization #SoftwareEngineering
To view or add a comment, sign in
-
-
✅ Day 20 of #DSAPrep > Problem: Move Zeroes > Platform: LeetCode > Concept: Two Pointers Solved this problem using the two-pointer approach to move all zeroes to the end while maintaining the order of non-zero elements. > Key Idea: - Use one pointer to track position of non-zero elements - Traverse array and swap non-zero elements forward - Keep zeroes at the end automatically > Time Complexity: O(n) > Space Complexity: O(1) #DSAPrep #Algorithms #Python #TwoPointers #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Remove Nth From End: Fixed-Gap Two Pointers for One-Pass Deletion Finding nth from end typically needs list length first (two passes). Optimization: maintain n-node gap between pointers. Advance second n steps, move both together — when second hits end, first is one before target. One pass only. Fixed-Gap Technique: Two pointers with fixed separation enable relative positioning without counting. Dummy handles head deletion edge case. This gap pattern appears in cycle detection, palindrome validation. Time: O(n) single pass | Space: O(1) #TwoPointers #FixedGap #LinkedList #OnePass #Python #AlgorithmDesign #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Tackled the Mean of Range in Array problem today using prefix sums for efficient query handling. Optimized to answer each query in constant time, ensuring platform‑ready performance and hidden test case compliance. #Geekstreak2026 #Geekstreak60 #GFG #Coding #Python #DSA #ProblemSolving #GeeksforGeeks #POTD Problem Link : https://lnkd.in/gE8qbfG6 Solution Link : https://lnkd.in/grPTmTvj
To view or add a comment, sign in
-
-
Solved “Construct K Palindrome Strings” today. The idea was interesting — instead of actually building palindromes, I focused on character frequency. Key insight: the number of characters with odd frequency must be ≤ k. Used Counter to count characters and checked if forming k palindromes is possible. Clean logic, no heavy coding just understanding the pattern. All test cases passed Learning that DSA is more about thinking than coding #DSA #CodingJourney #Python #LeetCode
To view or add a comment, sign in
-
-
Day 43/60 — GFG POTD Challenge 🔹 Problem: Consecutive 1’s Not Allowed 🔹 Approach: Dynamic Programming (Fibonacci pattern) 🔹 Time Complexity: O(n) 🔹 Space Complexity: O(1) Solved this problem by identifying a Fibonacci-like pattern to count valid binary strings without consecutive 1’s. Good practice for DP fundamentals! #geekstreak60 #npci #60DaysChallenge #GeeksforGeeks #POTD #DSA #DynamicProgramming #Python #ProblemSolving #ContinuousLearning
To view or add a comment, sign in
-
-
🚀 Day 4 of #LeetCode Challenge 🔍 Problem: Reverse Integer 💡 Approach: Reversed the integer digit by digit using modulo (%) and division (/). Extract last digit using % 10 Build reversed number using rev * 10 + digit Handle negative numbers using abs() Checked for 32-bit overflow condition 🧠 Key Concept: Digit manipulation + overflow handling without using extra space. 🔥 #Day4 #LeetCode #Python #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 50/60 #geekstreak60 Solved Intersection of Two Sorted Arrays today. A simple yet important problem that highlights the efficiency of the two-pointer approach — allowing us to find common elements in O(n + m) time while handling duplicates smartly. Problems like these may look basic, but they strengthen core DSA thinking and improve logic with every step. 💻 #geekstreak60 #npci #DSA #Python #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Group Anagrams: Frequency Array as Hashable Key Sorting each string costs O(k log k) per string. Character frequency array is O(k) and creates identical signature for anagrams. Fixed 26-element array converted to tuple serves as hashable HashMap key — faster, cleaner grouping. Frequency Signature: Character counts uniquely identify anagram groups without sorting. Tuple conversion makes array hashable for dict keys. Pattern applies to document clustering, duplicate detection. Time: O(n × k) vs O(n × k log k) sorting | Space: O(n × k) #FrequencyArray #Anagrams #HashMap #KeyOptimization #Python #AlgorithmOptimization #SoftwareEngineering
To view or add a comment, sign in
-
Explore related topics
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