🚀 𝗬𝗼𝘂 𝗰𝗼𝗺𝗽𝗿𝗲𝘀𝘀 𝟭𝟬 𝗚𝗕, 𝗴𝗲𝘁 𝟯 𝗚𝗕. 𝗬𝗼𝘂 𝗲𝘅𝘁𝗿𝗮𝗰𝘁, 𝗴𝗲𝘁 𝟭𝟬 𝗚𝗕 𝗯𝗮𝗰𝗸. 𝗪𝗵𝗲𝗿𝗲 𝗱𝗶𝗱 𝘁𝗵𝗼𝘀𝗲 𝟳 𝗚𝗕 𝗲𝘃𝗲𝗻 𝗴𝗼? Your file is full of repetition. Way more than you think. A video? Thousands of frames where the background doesn't change. A text file? The word "the" showing up hundreds of times. Code? Same patterns everywhere. The first algorithm, 𝗟𝗭𝟳𝟳, catches this. Instead of storing "the" for the 300th time, it leaves a tiny note - "copy what I wrote 200 bytes ago." That note is 3 bytes. The original was 50. Gone. Then 𝗛𝘂𝗳𝗳𝗺𝗮𝗻 steps in and looks at what's left. It notices some symbols appear constantly, others barely show up. So it gives short codes to the popular ones, longer codes to the rare ones. Like VIP lanes, frequent flyers board faster. Boom. 10 GB becomes 3 GB. Now extraction, The ZIP file secretly carries a codebook inside it. When you extract, it reads that map and works backwards. Huffman restores every symbol. LZ77 follows every pointer and pastes everything back. Byte by byte. Frame by frame. Pixel by pixel. Your original 10 GB, fully restored. Math didn't compress your file. Math just found a smarter way to tell the same story. #SoftwareEngineering #ComputerScience #Programming #TechForEveryone #LearningInPublic #Algorithms #Developer #CodingLife
More Relevant Posts
-
🚀 Day 15 of my DSA Grind Sometimes the best way to optimize a Sliding Window problem is to not use a window at all! Today, I tackled a LeetCode Medium that completely changed how I look at substring counting. 🔹 Number of Substrings Containing All Three Characters (LC 1358): The standard approach here is using a left and right pointer to expand and shrink a window until it contains 'a', 'b', and 'c'. But managing those pointers can get messy. The Breakthrough: I scrapped the traditional window and used the "Last Seen" Index array. I simply tracked the exact index where I most recently saw an 'a', a 'b', and a 'c'. The Math: To form a valid substring ending at my current position, I just need to reach back to the minimum of those three indices. Every single index before that minimum is a valid starting point! The Result: By applying the formula count += 1 + min(last_a, last_b, last_c), I reduced the problem to a single, lightning-fast O(N) pass with strict O(1) space. Zero nested loops, zero pointer rewinding! #DataStructures #Algorithms #LeetCode #CPP #ProblemSolving #SoftwareEngineering #PlacementPreparation #Optimization #100DaysOfCode #TechJourney
To view or add a comment, sign in
-
-
Continuing my 100 Days of DSA journey. Day 69 — LeetCode (Balanced Binary Tree) Balanced Binary Tree – Given a binary tree, determine if it is height-balanced (i.e., the heights of left and right subtrees of every node differ by no more than 1). Approach (DFS + Height Optimization): a) Use a recursive function to calculate the height of each subtree b) For each node, recursively get the height of left and right subtrees c) If any subtree returns -1, propagate -1 upwards (indicating imbalance) d) Check if the absolute difference between left and right heights is greater than 1 e) If unbalanced, return -1 immediately f) Otherwise, return 1 + max(leftHeight, rightHeight) Time Complexity: O(n) Space Complexity: O(h) (recursion stack) On to Day 70... #100DaysOfCode #DSA #LeetCode #Cpp #Algorithms #CodingJourney #ProblemSolving #SoftwareEngineering #InterviewPrep #LearningInPublic #geeksforgeeks #Microsoft #Greedy #Strings #Optimization
To view or add a comment, sign in
-
-
Most DSA problems don’t need complex logic. They need the right pattern. 📚 Today I learned: Prefix Sum 💡 What is Prefix Sum? A technique where we precompute cumulative sums to answer range queries efficiently. 👉 Instead of recalculating sums again and again, we store running totals. 💡 How to use it? Build a prefix array sum(L to R) = prefix[R] - prefix[L-1] 💡 When to use it? Multiple range sum queries Subarray sum problems Cumulative total calculations 💡 How to identify it? Repeated sum calculations Queries like “sum from L to R” Need to optimize from O(n²) → O(n) 💻 Practiced (LeetCode): #1480 Running Sum of 1D Array #303 Range Sum Query – Immutable #560 Subarray Sum Equals K #525 Contiguous Array ⚡ Key Insight: Precomputation can turn complex problems into simple ones. Learning one pattern at a time. Consistency is the real game 🚀 #DSA #leetcode #coding #algorithms #learning
To view or add a comment, sign in
-
🚀 Solved: Kth Smallest Number in Multiplication Table (LeetCode Hard) This problem really pushed me to think beyond brute force and apply Binary Search on Answer with an efficient counting strategy. 💡 Core Idea: We are given an m x n multiplication table, and we need to find the k-th smallest number. Instead of generating the entire table (which is inefficient), I searched directly in the value space. 🧠 Approach Breakdown: 1. Binary Search on Range i. Minimum possible value = 1 ii. Maximum possible value = m * n 2. Key Question: 👉 For a given number mid, how many values in the table are ≤ mid? 3. Efficient Counting (Greedy Traversal): i. Start from bottom-left of the table ii. If row * col ≤ mid, then all elements in that column up to that row are valid iii. Add row to count and move right iv. Otherwise, move up This avoids checking every cell and reduces complexity significantly. ⚡ Why this works? Because each row and column in the multiplication table is sorted, we can eliminate large portions of the search space in each step. ⏱️ Complexity: Time: O((m + n) * log(m*n)) Space: O(1) 🔥 Key Learning: Whenever you see: 1. “k-th smallest/largest” 2. Sorted structure (matrix, table, etc.) 👉 Think: Binary Search on Answer + Counting Function This problem was a great reminder that optimizing brute force often comes down to asking the right counting question. #DataStructures #Algorithms #DSA #BinarySearch #LeetCode #ProblemSolving #CodingInterview #Cpp #Programming #LearningInPublic #TechJourney
To view or add a comment, sign in
-
-
Continuing my 100 Days of DSA journey. Day 76 — LeetCode (Minimum Window Substring) - Hard Minimum Window Substring – Given two strings s and t, return the minimum window in s which will contain all the characters in t. If there is no such window, return an empty string. Approach (Sliding Window + Hashing): a) Use two hash maps to track required characters and current window frequency b) Maintain two pointers to represent the window (left and right) c) Expand the window by moving the right pointer and update frequency d) Keep track of how many required characters are satisfied e) When all characters are matched, try to shrink the window from the left f) Update the minimum window length whenever a valid window is found g) Continue the process until the entire string is traversed Time Complexity: O(n) Space Complexity: O(1) Key takeaway: Learned how combining sliding window with frequency tracking helps efficiently solve complex substring problems with multiple constraints. On to Day 77... #100DaysOfCode #DSA #LeetCode #Cpp #CyclicSort #Algorithms #CodingJourney #ProblemSolving #SoftwareEngineering #InterviewPrep #LearningInPublic #geeksforgeeks #Microsoft #SlidingWindow #Hashing #Strings #TwoPointers
To view or add a comment, sign in
-
-
🚀 Day 95 of #100DaysOfCode Today I explored an interesting concept in sorting algorithms — Comparison vs Non-Comparison Sorting. Most sorting algorithms like QuickSort or MergeSort rely on comparisons, which gives them a lower bound time complexity of O(n log n). But today I learned about Counting Sort, a non-comparison algorithm that can sort data in O(n) time under certain conditions 🔥 💡 Key Idea: Instead of comparing elements, Counting Sort counts the frequency of each value using an auxiliary array. 📌 Example: Input → [1, 1, 3, 2, 1] Frequency → [0, 3, 1, 1] Sorted Output → [1, 1, 1, 2, 3] ✨ When to use Counting Sort? ✔ When range of numbers is small ✔ When elements are integers ✔ When performance matters more than space ⚠ Limitation: ❌ Not suitable for large ranges ❌ Uses extra memory 📈 Time Complexity: O(n) 📦 Space Complexity: O(k) Learning this made me realize that the choice of algorithm depends heavily on the problem constraints, not just theory. Consistency is the key 🔑 #Day95 #CodingJourney #DataStructures #Algorithms #Sorting #100DaysOfCode #Learning #Programming
To view or add a comment, sign in
-
🔥 𝗨𝗽𝘀𝗼𝗹𝘃𝗶𝗻𝗴 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲 𝗪𝗲𝗲𝗸𝗹𝘆 𝗖𝗼𝗻𝘁𝗲𝘀𝘁 𝟰𝟵𝟲 — 𝗪𝗵𝗲𝗻 “𝗣𝗲𝗮𝗸𝘀” 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗗𝗣 𝗣𝘂𝘇𝘇𝗹𝗲 Today I revisited the hardest problem from the contest. At first glance, it looks like a small greedy task about making peaks in an array. It’s not. The moment you notice the array is 𝗰𝗶𝗿𝗰𝘂𝗹𝗮𝗿, the problem quietly turns into a 𝗱𝘆𝗻𝗮𝗺𝗶𝗰 𝗽𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴 challenge. 🧩 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 𝗶𝗱𝗲𝗮 You may increment any element. A peak is strictly greater than its two neighbors. First and last elements are also neighbors (circular). Create at least k peaks with minimum increments. 💡 𝗞𝗲𝘆 𝗿𝗲𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻 Two adjacent indices can never both be peaks. So this becomes a selection problem: Pick positions to be peaks (no two adjacent) while minimizing the cost to raise them. This matches the House Robber DP pattern. 🧠 𝗞𝗲𝘆 𝗶𝗱𝗲𝗮𝘀 𝘁𝗵𝗮𝘁 𝗺𝗮𝗸𝗲 𝗶𝘁 𝘄𝗼𝗿𝗸 1. Maximum possible peaks = n / 2 2. Cost to make index i a peak depends only on its two neighbors 3. If you choose index i, you must skip i-1 4. DP choice at every index: Skip it Or make it a peak and add its cost Handling the circular twist Because index 0 and n-1 are neighbors: 1. Run the DP on the original array 2. Run the DP on the reversed array 3. Take the minimum of both This converts a circular DP into a linear one. ✨ 𝗪𝗵𝘆 𝘁𝗵𝗶𝘀 𝗽𝗿𝗼𝗯𝗹𝗲𝗺 𝘀𝘁𝗮𝗻𝗱𝘀 𝗼𝘂𝘁 What looks like a simple greedy “raise numbers” task actually requires: 1. Recognizing a selection constraint 2. Modeling it as DP 3. Handling circular neighbors carefully 4. Thinking in patterns, not simulation A very satisfying upsolve — and a reminder that small constraints often hide deeper ideas. #LeetCode #LeetCodeContest #WeeklyContest #ContestUpsolve #DynamicProgramming #DP #HouseRobberPattern #CircularArray #ArrayProblems #AlgorithmDesign #ProblemSolving #CompetitiveProgramming #CodingPractice #DSA #DataStructures #Algorithms #TechLearning #DeveloperJourney #CodingLife #Upsolving
To view or add a comment, sign in
-
-
Continuing my 100 Days of DSA journey. Day 71 — LeetCode (Valid Parentheses) Valid Parentheses – Given a string containing just '(', ')', '{', '}', '[' and ']', determine if the input string is valid. A string is valid if open brackets are closed by the same type and in the correct order. Approach (Stack): a) Use a stack to keep track of opening brackets b) Traverse the string character by character c) If an opening bracket is encountered, push it onto the stack d) If a closing bracket is found: Check if the stack is empty → if yes, return false Otherwise, compare with the top of the stack If it matches the corresponding opening bracket, pop it Else, return false e) At the end, if the stack is empty → valid, otherwise invalid Time Complexity: O(n) Space Complexity: O(n) Key takeaway: Learned how stack helps in handling nested and ordered structures efficiently, especially in problems involving matching pairs. On to Day 72... #100DaysOfCode #DSA #LeetCode #Cpp #CyclicSort #Algorithms #CodingJourney #ProblemSolving #SoftwareEngineering #InterviewPrep #LearningInPublic #geeksforgeeks #Microsoft #Stack #Strings #Parentheses #DataStructures
To view or add a comment, sign in
-
-
I built rEcomment to bring Jupyter-style documentation into Antigravity. It renders LaTeX, tables, and rich text directly in the IDE runnable cells are just much more convenient than a notebook. Then I thought: why not just render Markdown and HTML in the comments and make them fun? Now you can use colors, tables, and math, and it just works. It started as a fun side-project but unexpectedly took off on the Marketplace. If you’re using Cursor, Windsurf, or VS Code, check it out!
To view or add a comment, sign in
-
-
I love when a simple function hides something much deeper. 🧩 Look at this: f(n) = n + diff Seems easy, right? But here's the catch — diff isn't fixed. It repeats: 5 → 4 → 3 → 2 → 1 → 0 → 5 → 4 → ... So the real puzzle is: which diff applies to which n? --- Here's what I found when I dug into it: 🔁 One line of code solves everything: diff = [5,4,3,2,1,0][n % 6] 📌 Every 6th number is a FIXED POINT — f(n) = n (the output equals the input) 🔀 Some sequences hide TWO rules taking turns: 2 → 6 → 7 → 21 → 22 → 66 → ? (×3, then +1, then ×3, then +1...) 📈 Some patterns grow in the differences, not the values: 1→2, 2→4, 3→7, 4→11, 5→? (+2, +3, +4, +5... so the answer is 16) --- The moment everything clicked: The % (modulo) operator is the key to unlocking repeating patterns in code. Once you see it, you can't unsee it. --- I've put together the full detailed solutions to all 13 questions in simple, easy-to-read English — attached as a PDF below 👇 If you enjoy this kind of logic puzzle, save this post — and try Q3 in the comments before peeking at the PDF! 😄 #Logic #ProblemSolving #Patterns #Programming #Puzzles #CriticalThinking #Coding #MathIsBeautiful
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