Day 40/100 – #100DaysOfCode 🚀 Solved LeetCode #2460 – Apply Operations to an Array (Python). Today I practiced array manipulation and simulation to apply given operations and rearrange elements efficiently. Approach: 1) Traverse the array and check adjacent elements. 2) If nums[i] == nums[i + 1], double nums[i] and set nums[i + 1] to 0. 3) After processing, collect all non-zero elements into a new list. 4) Count the number of zeros to be added. 5) Append remaining zeros at the end to maintain array size. Time Complexity: O(n) Space Complexity: O(n) Learning how to simulate operations step by step 💪 #LeetCode #Python #DSA #Arrays #ProblemSolving #100DaysOfCode
Solved LeetCode #2460 in Python
More Relevant Posts
-
Day 43/100 – #100DaysOfCode 🚀 Solved LeetCode #2610 – Convert an Array Into a 2D Array With Conditions (Python). Today I practiced hashmap (frequency counting) to construct a 2D array based on given conditions. Approach: 1) Create a frequency map to count occurrences of each element. 2) Initialize an empty result list. 3) While the frequency map is not empty: 4) Create a new row. 5) Iterate through keys and add each number once to the row. 6) Decrease its frequency and remove it if it becomes zero. 7) Add the row to the result. 8) Return the final 2D array. Time Complexity: O(n) Space Complexity: O(n) Learning how frequency maps help in structuring data efficiently 💪 #LeetCode #Python #DSA #HashMap #Arrays #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
DAY 53 🚀 – Bit Manipulation + Subsets 🔥 Exploring power sets and pattern expansion 💯 Day 53 / #120DaysOfCode – LeetCode Challenge ✅ Problem Solved: • 78. Subsets 💻 Language: Python 📚 Key Learnings: • Built subsets using iterative expansion technique • Understood relation to power set (2ⁿ combinations) • Learned alternative approach via bit manipulation • Strengthened understanding of combinatorics in coding 💡 Key Insight: Each element doubles the number of subsets → include / exclude 🔥 Progress: Moving deeper into patterns used in recursion & bit manipulation 💪 🔗 LeetCode Profile: https://lnkd.in/gbeMKcv5 #LeetCode #Python #DSA #BitManipulation #Subsets #Backtracking #Consistency #120DaysOfCode
To view or add a comment, sign in
-
-
Day 39/100 – #100DaysOfCode 🚀 Solved LeetCode #2215 – Find the Difference of Two Arrays (Python). Today I practiced set operations to efficiently find distinct elements between two arrays. Approach: 1) Convert both arrays into sets to remove duplicates. 2) Find elements present in nums1 but not in nums2 using set difference. 3) Find elements present in nums2 but not in nums1. 4) Convert both results back to lists. 5) Return the final list of differences. Time Complexity: O(n + m) Space Complexity: O(n + m) Understanding how set operations simplify comparison problems 💪 #LeetCode #Python #DSA #Sets #Arrays #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 62 of #100DaysOfCode Solved “Remove Nth Node From End of List” 🔗 💡 Today’s focus: Two Pointer Technique (Fast & Slow pointers) Instead of calculating length, I used an efficient one-pass approach to remove the target node. 🧠 Key Learnings: Dummy node helps handle edge cases (like removing head) Fast pointer moves n steps ahead Then move both pointers until fast reaches the end Slow pointer lands just before the node to delete ⚡ Clean, efficient & optimal solution (O(n) time, O(1) space) Consistency is starting to feel powerful now 💪 #DSA #LeetCode #CodingJourney #LinkedInLearning #100DaysOfCode #Day62 #Python #ProblemSolving
To view or add a comment, sign in
-
-
K Closest Points: Min-Heap for Efficient Selection Sorting all points costs O(n log n). Min-heap achieves same complexity but enables early termination — build heap with distances, extract k smallest. Squared distance avoids expensive sqrt while preserving ordering. Optimization Note: Max-heap of size k would be O(n log k) versus O(n log n) here. For small k, bounded heap beats full sorting. This solution works but isn't optimal for k << n. Time: O(n log n) | Space: O(n) #Heap #KClosest #DistanceCalculation #PriorityQueue #Python #AlgorithmDesign #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 33 – LeetCode Journey Today’s problem: Move Zeroes ✔️ Used two-pointer technique for in-place modification ✔️ Moved all non-zero elements forward efficiently ✔️ Maintained relative order of elements 💡 Key Insight: By keeping a pointer for non-zero elements, we can swap values in a single pass and avoid extra space — making the solution both clean and optimal. This problem improved my understanding of array manipulation and in-place algorithms. Consistency is building confidence day by day 💪🔥 #LeetCode #Day33 #Arrays #TwoPointers #Python #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 LeetCode Progress Update – Problem Solved! ✅ Problem: Remove Trailing Zeros From a String 💡 Approach: Used reverse traversal to find the first non-zero digit and sliced the string accordingly. 🔍 Key Learning: Efficient string manipulation can avoid unnecessary conversions. Traversing from the end helps solve trailing-based problems quickly. 💻 Code Insight: Instead of removing zeros one by one, I identified the breakpoint and sliced the string — making it optimal and clean. ⏱️ Performance: Runtime: 3 ms ⚡ Beat: 66%+ users Memory: 19.23 MB 📈 Consistency is key — one problem closer to mastery! #LeetCode #CodingJourney #Python #ProblemSolving #DSA #100DaysOfCode
To view or add a comment, sign in
-
-
Day 110 Same pattern, new constraint. #Day110 🧩 90. Subsets II How today went: • Very similar to the basic Subsets problem • First step: sort the array • While iterating, skip duplicate elements to avoid repeating subsets • Use the same backtracking pattern: append → recurse → pop What I learned: The core pattern stays the same — only the duplicate handling logic changes. This small condition makes a big difference. Backtracking is becoming more predictable now. #LeetCode #DSA #Python #Backtracking #Recursion #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
Day 24/100 – DSA Journey Problem: Intersection of Two Arrays Initially thought of using loops, but that would increase time complexity. Then realized the problem requires only unique common elements, which makes sets a perfect fit. Converted both arrays into sets and used intersection to directly get the result in an efficient way. Key Learning: Choosing the right data structure can simplify the entire problem. #Day24 #100DaysOfCode #DSA #Python #LeetCode #ProblemSolving
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