🚀Day 56 of #100DaysOfCode 🚀Solved LeetCode Problem 3347 – Maximum Frequency of an Element After Performing Operations II (Hard) This problem tested efficient use of sorting + sliding window technique to maximize element frequency after limited operations. The challenge was to determine how far we can extend a subarray where values can be adjusted within a range [-k, k] using at most num Operations modifications — achieving an optimized O(n log n) approach. Runtime: 266 ms — Beats 98.39% Memory: 31.96 MB — Beats 95.16% Key Concepts: Sorting for value proximity alignment Two-pointer technique for maintaining valid operation windows Cumulative operation cost calculation to ensure feasibility Feeling great to see consistent performance improvements and algorithmic clarity growing day by day! 🚀 #LeetCode #100DaysOfCode #Python #ProblemSolving #DataStructures #Algorithms
Solved LeetCode Problem 3347 with sorting and sliding window technique
More Relevant Posts
-
Day 33 / 100 – Maximum Average Subarray (LeetCode #643) Today’s challenge was about finding a contiguous subarray of length k with the maximum average. At first glance, it seems simple, but the key is doing it efficiently. By using a sliding window, I avoided recalculating sums for every subarray, which makes the solution both fast and elegant. This problem reminded me that small optimizations in logic can lead to huge improvements in performance, and thinking carefully about how to structure your solution is just as important as solving the problem itself. 🔍 Key Learnings Sliding window technique updates the sum in constant time for each step. Keeping track of the maximum sum while iterating avoids unnecessary computations. Always ensure floating-point division for correct average calculations. 💭 Thought of the Day Efficiency in coding comes from thinking smart, not from brute force. Sliding window allowed me to write clean and readable solutions while handling all edge cases. Today reinforced that solving problems isn’t just about getting a correct answer — it’s about writing solutions that are elegant, efficient, and scalable. 🔗 Problem Link:https://lnkd.in/gCVb4_pu #100DaysOfCode #Day33 #LeetCode #Python #SlidingWindow #ProblemSolving #Algorithms #DataStructures #CodingChallenge #CodeEveryday #LearningJourney #TechGrowth #Efficiency #CleanCode #PythonProgramming
To view or add a comment, sign in
-
-
🧠 Day 25 Theme: Recursion & Backtracking Concepts Covered Recursive calls and base conditions Decision tree and state-space exploration Backtracking for constraint satisfaction Handling duplicates and pruning branches Classic examples: combinations, permutations, subsets, and N-Queens 📚 Learn from These Resources 📘 Recursion Fundamentals 👉 https://lnkd.in/gPQvuduf 👉 https://lnkd.in/gt-mteqM 📗 Backtracking Algorithms 👉 https://lnkd.in/gaRCKvJT 👉 https://lnkd.in/g87eEpKa 📙 Visual Demos & Tutorials 👉 https://lnkd.in/g8FWB-Mq 👉 https://lnkd.in/g6Rt5zgf 🧩 Practice Ideas Generate all subsets of an array Solve permutations of numbers or strings N-Queens / Sudoku solver (classic backtracking) Word search (DFS + backtracking combo) Combinations that sum to target (like Combination Sum I/II) #75DaysOfKnowledge #Recursion #Backtracking #ProblemSolving #CodingJourney #LeetCode #AlgorithmicThinking #Java #Python #Programming
To view or add a comment, sign in
-
🚀 Day 87/100 of the #100DaysOfCode Challenge! #Day87 of #100Dayscodingchallenge:Today's focus was on mastering control flow and precision with nested loops in Python. I tackled a series of classic pattern problems that are fantastic for understanding logical structuring and boundary conditions. The Challenge: Build hollow geometric patterns using only for loops and conditional statements. Patterns Solved: ✅ Hollow Pyramid: A test of symmetry and managing increasing spaces. ✅ Hollow Right-Angled Triangle: Focusing on the first and last elements of each row. ✅ Inverted Hollow Pyramid: The reverse logic of its upright counterpart. ✅ Hollow Diamond: Combining the logic of both the standard and inverted pyramids for a complex, symmetrical shape. These exercises are more than just printing stars; they're about sharpening problem-solving skills, breaking down complex problems into manageable steps, and writing efficient, clean code. It's a powerful reminder that solid fundamentals in loops and conditionals are the building blocks for more advanced algorithms. Check out the code snippet in the comments! 👇 #Nxtwave #ccbp #intensive #Python #Programming #CodingChallenge #Algorithms #ProblemSolving #SoftwareDevelopment #LearnToCode #CodeNewbie #Developer #ProgrammingPatterns
To view or add a comment, sign in
-
🔥 Day 61 of #100DaysOfCode 💡 LeetCode Problem 2125 – Number of Laser Beams in a Bank (Medium) Today’s challenge focused on analyzing a 2D binary matrix representing a bank floor plan equipped with anti-theft laser security devices. Each ‘1’ indicates a device, and each ‘0’ indicates an empty cell. The goal was to determine how many laser beams exist between devices on different rows, ensuring no other row between them contains any active devices. 🧠 Key Idea: Count the number of ‘1’s (active devices) in each row. For every non-empty row, multiply its device count by the previous non-empty row’s count — this gives the number of beams formed between them. ⚙️ Approach: Traverse each row. Count devices ('1') in that row. If the row is not empty, add prev * curr to the result. Update prev as the current count for the next iteration. 💻 Code (Python): class Solution: def numberOfBeams(self, bank: List[str]) -> int: prev, result = 0, 0 for row in bank: curr = row.count('1') if curr: result += prev * curr prev = curr return result 📈 Result: ✅ Runtime: 5 ms — Beats 80.12% ✅ Memory: 19.34 MB — Beats 93.57% 🧩 Concepts Applied: String traversal Matrix interpretation Counting and dynamic accumulation Each day’s challenge continues strengthening my logic-building and Python efficiency. 🚀 #LeetCode #100DaysOfCode #Python #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
-
𝘌𝘷𝘦𝘳 𝘭𝘰𝘰𝘬𝘦𝘥 𝘢𝘵 𝘺𝘰𝘶𝘳 𝘋𝘰𝘤𝘬𝘦𝘳 𝘪𝘮𝘢𝘨𝘦 𝘴𝘪𝘻𝘦 𝘢𝘯𝘥 𝘵𝘩𝘰𝘶𝘨𝘩𝘵… 𝘵𝘩𝘢𝘵 𝘤𝘢𝘯’𝘵 𝘣𝘦 𝘳𝘪𝘨𝘩𝘵? 𝐓𝐡𝐢𝐬 𝐰𝐚𝐬 𝐦𝐞 𝐥𝐚𝐬𝐭 𝐰𝐞𝐞𝐤! Here is the fix: 1. Switched to a lightweight base image Moved from python:3.11 to python:3.9-alpine. Just that change cut the image size by 95%. 2. Optimised layers Grouped related commands to reduce redundant RUN instructions. Fewer layers, faster builds. 3. Added a .dockerignore file Excluded things like virtual environments, cache, and temp files. It made the build context much lighter. 4. Used multi-stage builds First stage for building dependencies. Second stage for production — only what’s needed at runtime. 𝘛𝘩𝘦 𝘳𝘦𝘴𝘶𝘭𝘵𝘴 ? Image size: 47.7 MB (down from 588 MB) Size reduction: −91.89% Faster container startup Reduced deployment time and storage usage Repo in the Comments 👇🏿
To view or add a comment, sign in
-
-
🧩 Day 38 / 100 – Transpose Matrix (LeetCode #867) Today’s problem focused on understanding matrix manipulation — specifically, the Transpose of a matrix. Transposing means flipping a matrix over its diagonal, turning rows into columns and columns into rows. It’s a simple concept but helps strengthen 2D array traversal logic — especially how to navigate nested loops cleanly and avoid index confusion. This was a good reminder that clarity and structure matter just as much as complexity. 🔍 Key Learnings Transposing a matrix means swapping element positions — matrix[i][j] → result[j][i]. Use nested loops efficiently to fill the new matrix with swapped indices. Always keep track of dimensions — rows become columns and vice versa. 💭 Thought of the Day Even small transformations like a transpose can teach big lessons in clean logic. Sometimes we overthink “hard” problems, but mastering basics like matrix traversal builds the foundation for solving advanced ones like rotation or dynamic programming grids. 🔗 Problem Link:https://lnkd.in/gHKB9h4b #100DaysOfCode #Day38 #LeetCode #Python #Matrix #Transpose #ProblemSolving #Algorithms #DataStructures #CodingChallenge #CodeEveryday #LearningJourney #CleanCode #TechGrowth #PythonProgramming
To view or add a comment, sign in
-
-
🚀 Leetcode #3289. The Two Sneaky Numbers of Digitville Recently, I solved an interesting problem focused on detecting duplicate elements in a list of integers. 💡 Problem Statement: Given an integer array nums, return all elements that appear exactly twice. 🔍 Approach: - Initialize a boolean list seen to track whether each number has been encountered. - Traverse the array once: - If a number is already marked as seen, append it to the result list. - Otherwise, mark it as seen. - Return the list containing all duplicate values. ⚙️ Complexity: - Time: O(n) - Space: O(n) ✨ Key Takeaways: - Boolean tracking arrays provide an efficient alternative to hash maps for frequency detection. - Maintaining clean traversal logic helps achieve clarity and optimal performance. #Python #DataStructures #Algorithms #Coding #ProblemSolving #LeetCode #Programming #Efficiency #DSA
To view or add a comment, sign in
-
-
🧠 Day 44 / 100 – Product of Array Except Self (LeetCode #238) Today’s challenge was all about computing an array where each element is the product of all numbers except itself — without using division. This one teaches prefix and suffix logic beautifully. The trick is to build two running products: One from the left (prefix) One from the right (suffix) Then combine both to get the final result. No division needed, no nested loops — just clean, efficient logic. 🔍 Key Learnings Use prefix and suffix multiplications for O(n) time complexity. Avoid division to handle zero cases efficiently. Think about how to reuse partial results rather than recomputing them. 💭 Thought of the Day Efficiency comes from rethinking the obvious. Instead of brute-forcing every combination, using prefix and suffix logic shows how planning ahead can simplify everything. Each day, I’m learning to design solutions, not just write them. 🔗 Problem Link: https://lnkd.in/gbGfa4dd #100DaysOfCode #Day44 #LeetCode #Python #Arrays #PrefixSum #ProblemSolving #Algorithms #DataStructures #EfficientCoding #CodeEveryday #LearningJourney #TechGrowth #CleanCode
To view or add a comment, sign in
-
-
Today, I played around with integrating a minimal Knowledge Graph into a RAG pipeline using NetworkX. The idea is simple: represent knowledge as connected nodes (concepts, facts, or entities) and visualize their relationships. Then, when you query the system, it can retrieve not just direct data but contextually related information from neighboring nodes. Here’s a small Python snippet I used to: >Build a graph from a DataFrame using nx.from_pandas_edgelist() >Query a node to extract its subgraph >Visualize relationships dynamically with Matplotlib This is prototyping but still it’s cool how even a small graph can make retrieval feel more semantic.
To view or add a comment, sign in
-
-
🚀 Day 41 of #100DaysOfDSA Solved LeetCode Problem #70 – Climbing Stairs 🪜✨ 📌 Problem Insight: You are climbing a staircase with n steps, and you can take either 1 step or 2 steps at a time. The task is to find the number of distinct ways to reach the top. A classic problem that beautifully introduces Dynamic Programming concepts! 💡 Key Learnings: Understood how this problem relates to the Fibonacci sequence. Practiced iterative DP optimization — using only two variables instead of an array. Learned how to recognize recurrence relations in real problems. Time complexity: O(n) Space complexity: O(1) 📌 Approach (short): Each step can be reached either from (n−1) or (n−2) → ways(n) = ways(n-1) + ways(n-2) 👉 Dynamic Programming problems show that thinking ahead pays off — one step at a time 🧠💪 #LeetCode #DSA #ProblemSolving #100DaysChallenge #Day41 #CodingJourney #Python #DynamicProgramming
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