🚀 [Day 15/30] Coding Challenge with @Educative.io 💻 💡 Problem: Subarrays with K Different Integers Today’s challenge was a great exercise in sliding window + counting techniques. The goal was to count subarrays that contain exactly K distinct integers. The key insight that made this problem click: 👉 Counting “exactly K” is easier if we count (at most K) − (at most K − 1). My approach: 1️⃣ Used a sliding window with a frequency map to count subarrays with at most K distinct integers 2️⃣ Reused the same logic to compute at most (K − 1) 3️⃣ Subtracted the two results to get exactly K distinct subarrays This avoided nested loops and kept the solution in O(n) time. ✨ Small win: Turning a complex “exactly” condition into two simpler “at most” problems made the solution both elegant and efficient. 🔍 Key Learnings: Sliding window patterns are extremely powerful for subarray problems Breaking problems into reusable components simplifies logic “Exactly K” often hides a smart counting trick #30DaysOfCode #Day14 #CodingChallenge #Educative #DSA #SlidingWindow #HashMap #Algorithms #JavaScript #ProblemSolving #InterviewPrep #SoftwareEngineer #LearningInPublic #TechCareers #KeepCoding
30 Days of Code: Subarrays with K Distinct Integers Challenge
More Relevant Posts
-
Day 8 of 30-day Coding Sprint Today’s focus was on a classic problem that teaches you why linear time isn't always good enough when dealing with exponents. Today's progress on LeetCode: 50. Pow(x, n) The Simple Recursive Approach: Multiplying x by itself n times. - Complexity: O(n) time. - The Issue: For large values of n, this hits the stack limit or simply takes too long. The Optimal Strategy: Binary Exponentiation (Divide & Conquer) - The Logic: Use the property (x^n) = (x^n/2)^2. By halving n at each recursive step, we drastically reduce the number of multiplications. The Result: O(log n) time. This turns a billion operations into roughly 30. #30DaysOfCode #DSASprint #LeetCode #JavaScript #Recursion #Math #Consistency
To view or add a comment, sign in
-
-
Day 183: Making Progress with Linked Lists I am on Day 183 of my coding journey. Today, I solved 3 more problems using Linked Lists. Here is what I learned in simple words: 1. Odd Even Linked List (LeetCode 328) I learned how to group nodes together. I put all nodes at odd positions first, and then all nodes at even positions. It is like re-arranging a line of people based on their number. 2. Add Two Numbers (LeetCode 2) I added two numbers where each digit is a node in a list. The most important part was learning how to handle the "carry" (like when $8 + 5 = 13$, you keep 3 and carry over the 1). 3. Merge Two Sorted Lists (LeetCode 21) I took two sorted lists and joined them into one big sorted list. I used a "Dummy Node" at the start. This trick made my code much shorter and easier to write. Key Lesson: In Linked Lists, you don't need to move the data. You just change where the "next" pointer points. It's like changing the signs on a road! #JavaScript #Coding #WebDev #Learning #Software #Programming #Logic #SimpleCode #DataStructures #Algorithms #Tech #Career #Success #Engineer #DailyCode #LinkedIndev
To view or add a comment, sign in
-
🚀 [Day 18/30] Coding Challenge with @Educative.io 💻 💡 Problem: Invert Binary Tree Today’s challenge was a classic tree problem — inverting a binary tree by swapping the left and right children of every node. The logic was simple yet powerful: 👉 Traverse the tree and swap left ↔ right at each node. I approached it using recursion: 1️⃣ Swap the left and right child 2️⃣ Recursively apply the same logic to both subtrees This can also be solved iteratively using BFS or DFS, but recursion keeps the solution very clean and readable. ✨ Small win: Problems like this remind me how elegant tree recursion can be — minimal code, clear intent. 🔍 Key Learnings: Tree transformations are often recursive by nature Preorder traversal works well for structural changes Simple problems still reinforce core fundamentals #30DaysOfCode #Day18 #CodingChallenge #Educative #DSA #BinaryTree #Recursion #Algorithms #JavaScript #ProblemSolving #InterviewPrep #SoftwareEngineer #LearningInPublic #TechCareers #KeepCoding
To view or add a comment, sign in
-
Day 17 of 30-day Coding Sprint Today I’ve shifted focus to one of the most efficient techniques in a developer's toolkit: The Sliding Window. 3. Longest Substring Without Repeating Characters - The Challenge: Finding the length of the longest substring where every character is unique. A naive O(n^2) approach would be too slow for large strings. - The Strategy: Optimized Sliding Window Used a Frequency Hash Array (represented as a 256-element array) to store the last-seen index of each character. Two pointers, l (left) and r (right), define the current window. - The Optimization: Instead of moving the left pointer l one by one when a duplicate is found, I "jump" 1 directly to hash[s[r]] + 1. This ensures that the window always contains unique characters in the most efficient way possible. Result: A clean O(n) time complexity with a single pass through the string. Note: The sliding window isn't just about moving pointers; it's about maintaining a state (in this case, uniqueness) and shrinking or expanding the boundaries to satisfy that state. Using a hash array to store indices turns an O(n) "shrink" into an O(1) "jump." #30DaysOfCode #DSASprint #LeetCode #JavaScript #SlidingWindow #Optimization #Consistency
To view or add a comment, sign in
-
-
𝗪𝗲𝗹𝗰𝗼𝗺𝗲 𝘁𝗼 𝗗𝗮𝘆 𝟭𝟯 𝙃𝙤𝙬 𝙅𝙖𝙫𝙖𝙎𝙘𝙧𝙞𝙥𝙩 𝙂𝙖𝙧𝙗𝙖𝙜𝙚 𝘾𝙤𝙡𝙡𝙚𝙘𝙩𝙞𝙤𝙣 𝙒𝙤𝙧𝙠𝙨 Your code doesn’t free memory. JavaScript does. But it only removes what is unreachable. 𝙍𝙚𝙖𝙘𝙝𝙖𝙗𝙞𝙡𝙞𝙩𝙮 An object stays in memory if there is a reference path from the roots. Roots: • Global scope • Execution stack • Active closures No path → eligible for garbage collection. 𝙈𝙖𝙧𝙠 & 𝙎𝙬𝙚𝙚𝙥 • Start from the roots and mark all reachable objects • Remove everything unmarked Reachable stays. Unreachable is freed. 𝙂𝙚𝙣𝙚𝙧𝙖𝙩𝙞𝙤𝙣𝙖𝙡 𝘾𝙤𝙡𝙡𝙚𝙘𝙩𝙞𝙤𝙣 Most objects die young. Memory is divided into: • Young generation → short-lived objects, frequent fast cleanup • Old generation → long-lived objects, less frequent cleanup 𝙋𝙧𝙤𝙢𝙤𝙩𝙞𝙤𝙣 Every object starts in the young generation. If it survives multiple GC cycles or memory pressure increases, it gets promoted to the old generation. Survival determines placement. 𝙒𝙝𝙮 𝙈𝙚𝙢𝙤𝙧𝙮 𝙇𝙚𝙖𝙠𝙨 𝙎𝙩𝙞𝙡𝙡 𝙃𝙖𝙥𝙥𝙚𝙣 GC removes only unreachable objects. Leaks occur when references are retained: • Globals • Closures • Timers / event listeners • Growing caches 𝘎𝘊 𝘸𝘰𝘳𝘬𝘴 𝘤𝘰𝘳𝘳𝘦𝘤𝘵𝘭𝘺. 𝘠𝘰𝘶𝘳 𝘳𝘦𝘧𝘦𝘳𝘦𝘯𝘤𝘦𝘴 𝘥𝘦𝘤𝘪𝘥𝘦 𝘸𝘩𝘢𝘵 𝘭𝘪𝘷𝘦𝘴. #JavaScript #WebDevelopment #SoftwareEngineering #FrontendDevelopment #Programming #Coding #Developers #TechCommunity #ComputerScience #PerformanceOptimization #Learning #ContinuousLearning #LearnInPublic
To view or add a comment, sign in
-
-
🚀 [Day 17/30] Coding Challenge with @Educative.io 💻 💡 Problem: Split Array Largest Sum Today’s challenge was an interesting mix of binary search + greedy validation. The goal was to split an array into m subarrays such that the largest subarray sum is minimized. The key insight: 👉 If we fix a maximum allowed subarray sum, we can greedily check whether the array can be split into at most m parts. My approach: 1️⃣ Set the search space between max(nums) and sum(nums) 2️⃣ Used binary search to guess the optimal maximum sum 3️⃣ For each guess, greedily counted how many subarrays were needed 4️⃣ Adjusted the search range based on feasibility This turned a complex optimization problem into a clean decision problem.| ✨ Small win: Realizing how “minimize the maximum” problems often map directly to binary search was a big confidence booster. 🔍 Key Learnings: Binary search isn’t just for sorted arrays Greedy checks pair perfectly with binary search Optimization problems often hide feasibility checks #30DaysOfCode #Day17 #CodingChallenge #Educative #DSA #BinarySearch #Greedy #Algorithms #JavaScript #ProblemSolving #InterviewPrep #SoftwareEngineer #LearningInPublic #TechCareers #KeepCoding
To view or add a comment, sign in
-
I experimented with vibe coding using Claude and built a small end-to-end SDET-style automation project. Simple BE + FE app → Docker Compose → Playwright in Docker → GitHub Actions CI. Video walkthrough: https://lnkd.in/guSY_8HM Repo: https://lnkd.in/g2Stt_Qm How I approached it: Described the target architecture + stack to the LLM (FastAPI, Python, SQLite, React) Asked it to generate an action plan Split the plan into modules Turned each module into a separate instruction file and implemented step by step You can follow it in two ways: Feed the module instruction files to an LLM (Claude Code works well) Or follow the instructions yourself and use the LLM only when you’re stuck (better for learning) Instruction files are available on Patreon (plan + Module1–Module7). https://lnkd.in/gUZ2YWUQ This is roughly how I see modern SDET-level automation evolving: less boilerplate, more system thinking, still owning CI, containers, and test strategy. Curious how others are using LLMs in real automation work. #SDET #QAAutomation #Playwright #Docker #GitHubActions #FastAPI #React #AIcoding #Claude
To view or add a comment, sign in
-
-
Introducing Smart Code Assistant (SCA) CLI – Your Offline Coding Companion As developers, we often switch between coding IDEs and browsers to look up solutions, which research shows can cause up to 30% loss of attention. Notifications and internet distractions make it even worse, eating into our precious coding time. To solve this, our team developed Smart Code Assistant (SCA) – a fully offline CLI tool that helps you test, debug, optimize, and understand your code without ever leaving your IDE. ⚡ Key Features Explain Code: Generates clear explanations of your code directly in your project directory. Debug: Identifies and fixes errors efficiently. Optimize: Suggests better approaches to improve your code. Test: Creates edge test cases to ensure your code is robust. 🛠 How It Works Install Ollama 3.2:1B model on your PC - https://lnkd.in/gMdtwFkM Install our package in your project directory - https://lnkd.in/gZaCXvbf Run commands like: sca test <file_name> sca debug <file_name> sca optimize <file_name> sca explain <file_name> All outputs are generated locally, so there’s no distraction from internet tabs or notifications. Core Contributors: Deepak Kambala and Akhil Siva Chowdary Nandigam Other Contributors: Vinay sai pavan Banduchode, Lourdhu Mounika Nare and Akhila Mokkapati 🔗 Check it out on PyPI: https://lnkd.in/gZaCXvbf 💡 Stay focused, code smarter, and keep distractions away!
To view or add a comment, sign in
-
I threw together a small learning project using Claude Hooks and some TypeScript to invoke dependency scanning with Socket CLI. It's not ideal to let Agentic Coding tools add dependencies blindly, but with some guardrails it can reduce some risk. Using Claude Hooks and TypeScript, I was able to use Socket to scan the dependency, log the result, make use of Claude Code's PreToolUse format to either deny, allow, or ask to proceed the adding of the dependency. The PreToolUse Decision Control gives you a seamless way to decide whether to allow a new dependency. The full write up is in the comments and a link to the source code is included in the blog post.
To view or add a comment, sign in
-
✨TypeScript's any vs unknown — Which one do you use? Most of us grab any for quick fixes, but it can hide bugs until runtime. unknown forces validation, making your code safer from the start. It's not about more typing. It's about writing smarter, more reliable code. 👉 Want the simple breakdown? I covered any, unknown, null, and undefined with clear examples here: https://lnkd.in/g9i8xSWr #TypeScript #WebDevelopment #ProgrammingTips #Coding #JavaScript #FullStackDevelopment
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