Day 5/100 – LeetCode Challenge 🚀 Problem: Intersection of Two Arrays Optimized approach: Used HashSet to store elements of the first array Checked presence while iterating the second array Stored unique intersection values Time Complexity: O(n + m) Space Complexity: O(n) Key takeaway: Hashing removes the need for sorting and nested loops, leading to cleaner and faster solutions. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #InterviewPrep #100DaysOfLeetCode
LeetCode Challenge: Intersection of Two Arrays
More Relevant Posts
-
Day 18/100 – LeetCode Challenge 🚀 Problem: Merge Sorted Array Approach: Used three pointers starting from the end of the arrays Compared elements from nums1 and nums2 Placed the larger element at the last available position in nums1 Time Complexity: O(m + n) Space Complexity: O(1) (in-place) Key takeaway: When merging arrays in-place, working from the end avoids unnecessary shifting of elements. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #InterviewPrep #100DaysOfLeetCode
To view or add a comment, sign in
-
-
Day 25/100 – LeetCode Challenge 🚀 Problem: Plus One Approach: Traversed digits from right to left Handled carry when the digit was 9 Created a new array only when all digits were 9 Time Complexity: O(n) Space Complexity: O(1) Key takeaway: Many array problems that involve arithmetic operations require careful carry handling from the end of the array. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #InterviewPrep
To view or add a comment, sign in
-
-
Day 27/100 – LeetCode Challenge 🚀 Problem: Sort List Approach: Applied Merge Sort on the linked list Used slow and fast pointers to find the middle Recursively sorted both halves Merged the sorted halves Time Complexity: O(n log n) Space Complexity: O(log n) (recursion stack) Key takeaway: Merge sort is the most efficient sorting technique for linked lists, as it avoids random-access operations required by other algorithms. #LeetCode #100DaysOfCode #DSA #Java #LinkedList #MergeSort #ProblemSolving
To view or add a comment, sign in
-
-
Day 8/100 – LeetCode Challenge 🚀 Problem: Implement strStr() Approach: Checked every possible starting index in haystack Matched characters one by one with needle Time Complexity: O(n × m) Space Complexity: O(1) Key takeaway: Brute-force solutions are fine when constraints allow them. Understanding the basic approach comes before optimization. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #100DaysOfLeetCode
To view or add a comment, sign in
-
-
Day 13/100 – LeetCode Challenge 🚀 Problem: Binary Search Approach: Maintained left and right pointers Compared middle element with target Reduced the search space by half each step Time Complexity: O(log n) Space Complexity: O(1) Key takeaway: Binary search is the foundation for solving problems with logarithmic efficiency. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #InterviewPrep #100DaysOfLeetCode
To view or add a comment, sign in
-
-
Day 30/100 – LeetCode Challenge 🚀 Problem: Count Binary Substrings Approach: Counted consecutive groups of 0’s and 1’s For every adjacent pair of groups, added min(prevGroup, currGroup) to the result Avoided generating substrings explicitly Time Complexity: O(n) Space Complexity: O(1) Key takeaway: Many substring problems don’t require generating substrings — they can be solved by analyzing group patterns and transitions. #LeetCode #100DaysOfCode #DSA #Java #Strings #ProblemSolving
To view or add a comment, sign in
-
-
Day 20/100 – LeetCode Challenge 🚀 Problem: Subsets (Power Set) Approach: Started with an empty subset For each number in the array, created new subsets by adding the number to all existing subsets Appended the newly formed subsets to the result list Time Complexity: O(n × 2ⁿ) Space Complexity: O(n × 2ⁿ) (to store all subsets) Key takeaway: Many combinatorial problems can be solved by building results incrementally, expanding previously generated subsets. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #Backtracking #100DaysOfLeetCode
To view or add a comment, sign in
-
-
Day 12/100 – LeetCode Challenge 🚀 Problem: Guess Number Higher or Lower Approach: Applied Binary Search Narrowed the search space based on feedback from the API Time Complexity: O(log n) Space Complexity: O(1) Key takeaway: Whenever the problem gives “higher or lower” feedback, binary search should be your first instinct. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #InterviewPrep #100DaysOfLeetCode
To view or add a comment, sign in
-
-
Day 68/100 – LeetCode Challenge ✅ Problem: #169 Majority Element Difficulty: Easy Language: Java Approach: Boyer-Moore Voting Algorithm Time Complexity: O(n) Space Complexity: O(1) Key Insight: Majority element appears more than n/2 times. Pair each occurrence of candidate with a different element to cancel out. The surviving candidate after pairing is the majority element. Solution Brief: Phase 1: Find potential candidate: Initialize ele with first element, cnt=1 For each element: if same → increment count, else decrement When count reaches 0, pick new candidate Phase 2: Verify candidate actually appears > n/2 times #LeetCode #Day68 #100DaysOfCode #Array #Java #Algorithm #CodingChallenge #ProblemSolving #MajorityElement #EasyProblem #BoyerMoore #VotingAlgorithm #DSA
To view or add a comment, sign in
-
-
🚀 Day 14 of #100DaysOfCode Solved Merge Two Sorted Lists on LeetCode 🔗🔀 🧠 Key insight: Using a dummy (sentinel) node simplifies pointer handling and avoids edge cases when building the merged list. ⚙️ Approach: 🔹Initialize a dummy node to act as the start of the merged list 🔹Compare nodes from both lists one by one 🔹Attach the smaller node and move the pointer forward 🔹Append remaining nodes once one list is exhausted ⏱️ Time Complexity: O(n + m) 📦 Space Complexity: O(1) #100DaysOfCode #LeetCode #DSA #LinkedList #Java #ProblemSolving #LearningInPublic #CodingJourney
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