🚀 Day 1 of My DSA Journey – Solved LeetCode Problem #66 (Plus One) 💡 Today I worked on the “Plus One” and "Single Number " problem from LeetCode using JavaScript. 🔢 1.Problem Summary: Given an array of digits representing a number, add one to the number and return the result as an array. 💭 What I Learned: • Handling edge cases (especially when digit = 9) • Understanding carry forward logic • Thinking from Right → Left (LSD to MSD) • Why simple problems test core fundamentals The interesting part? 🤯 When a digit is 9, we convert it to 0 and carry 1 to the previous digit. If all digits are 9 → we add 1 at the beginning using unshift(). Small problem. Big learning. Strong fundamentals. 💪 🔢 Problem #136 – Single Number Summary: Given an array where every number appears twice except one, find the number that appears only once. 💡 Key Learning: • XOR (^) cancels duplicates automatically • Only the unique number remains • Time Complexity = O(n), Space Complexity = O(1) ✅ • Pattern recognition is 🔑: “Duplicates cancel → Unique remains” 🎯 Goal: Solve 5 problems daily Master Data Structures & Algorithms Become interview ready for product-based companies Consistency > Motivation 🔥 #DSA #LeetCode #JavaScript #ProblemSolving #SoftwareEngineer #100DaysOfCode
LeetCode Challenge: Plus One & Single Number Problems
More Relevant Posts
-
🚀 LeetCode Problem Solved - Best Time to Buy and Sell Stock Today I solved the Best Time to Buy and Sell Stock problem on LeetCode using JavaScript with an optimized single-pass approach. 📊 Approach The goal is to determine the maximum profit from buying and selling a stock given its daily prices. The key idea is to: • Track the minimum price encountered so far • Calculate the potential profit for each day • Update the maximum profit whenever a higher profit is found This allows us to compute the result in one pass through the array. ⚡ Complexity 🔹 Time Complexity: O(n) – Traverse the prices array once 🔹 Space Complexity: O(1) – No extra data structures used ✅ Result ✔️ All test cases passed 📦 Constant space complexity Problems like this reinforce the importance of array traversal, state tracking, and optimizing brute-force solutions into efficient linear algorithms. Consistent practice with these problems strengthens DSA fundamentals and problem-solving skills for coding interviews. #leetcode #javascript #dsa #algorithms #codingpractice #softwareengineering #webdevelopment
To view or add a comment, sign in
-
-
Leetcode Day 1 : Problem 1 (Merge Sorted Array) Just solved my first LeetCode problem. It was the classic "Merge Sorted Array" sounds simple, right? But here's what I actually learned: JavaScript's .sort() doesn't sort numbers by default, it sorts them as strings. [1, 10, 2] becomes [1, 10, 2] not [1, 2, 10]. A one-line bug that would fail silently. Reassigning an array variable (arr = []) doesn't modify the original. LeetCode wants in-place changes. That took me a moment. I was filtering out zeros thinking they were empty slots, but 0 is a perfectly valid element. Hidden test cases would've caught me. Three bugs. One "easy" problem. Tons of learning. The real lesson? Passing the visible test cases doesn't mean your code is correct. Always think about edge cases. If you've been putting off starting DSA Interview questions like I was just open problem 1 and start. The first step is the hardest. #DSA #LeetCode #JavaScript #CodingJourney #Programming
To view or add a comment, sign in
-
-
Building on the basics of JavaScript, I’ve gained a solid understanding of how core components build a functional system. Writing code is the heart of this process, and seeing these concepts integrate is a major highlight of my learning. I have been practicing variable assignments using let, const, and var, while using typeof to identify different data types. I also learnt how to structure Control Flow through if/else statements, switch cases, and comparison operators. By using logical operators—specifically AND (&&) and OR (||)—along with strict equality (===), I can now set multiple rules for my code. I understand how to ensure that if a primary condition isn't met, the "else" logic applies correctly so the program follows a specific path. I also learnt how to use for loops combined with the .length property. This allows the code to automatically track the number of characters or items in a dataset. Instead of hard-coding values, I can now write dynamic code that adjusts to the data it receives. I am still working through the fundamentals, and I am excited to see how everything will work together once the foundation is complete! #JavaScript #WebDevelopment #CodingJourney #SoftwareEngineering #Techcrush #Frontend
To view or add a comment, sign in
-
-
🚀 LeetCode Problem Solved – Reverse String Solved the Reverse String problem on LeetCode using JavaScript with an optimized in-place approach. ✅ Key Idea: Reverse the string by swapping characters from the start and end of the same array, modifying it directly without creating any extra array. 🔹 Time Complexity: O(n) 🔹 Space Complexity: O(1) – No extra space used (in-place modification) 💡 Approach: • Use a two-pointer technique • One pointer starts from the beginning of the array • Another pointer starts from the end • Swap characters and move both pointers toward the center until they meet 📊 Result ✔️ All test cases passed ⚡ Runtime: 0 ms 📦 Space Complexity: O(1) Consistently practicing problems like this helps strengthen Data Structures & Algorithms fundamentals and improves problem-solving skills for coding interviews. #leetcode #javascript #dsa #twopointers #programming #codingpractice #softwareengineering
To view or add a comment, sign in
-
-
🚀 DSA Learning (Realization while solving Top K Frequent Elements) My initial approach was simple: 👉 Count frequency of each number using a HashMap 👉 Then compare frequency with k and push elements into a result array But then I got stuck… ❓ I tried to use .map() directly on the HashMap — and it didn’t work That’s when I realized: - Map is not an array, so array methods like .map() won’t work on it - What actually works: First convert the map into an array 👇 Array.from(map.entries()) Then: ✔️ sort by frequency ✔️ take top k ✔️ extract elements That small shift in understanding made the whole problem click 💡 #DSA #JavaScript #CodingJourney #LeetCode
To view or add a comment, sign in
-
-
Nobody taught me destructuring in college. So I wrote this for 6 months straight. 😭 ━━━━━━━━━━━━━━━━ ❌ Before: const name = user.name; const age = user.age; const city = user.address.city; ✅ After: const { name, age, address: { city } } = user; ━━━━━━━━━━━━━━━━ Works with arrays too: const [first, ...rest] = items; And function params: function greet({ name, age }) { ... } One of those features where once you start using it you physically cannot go back. 😂 #JavaScript #WebDev #LearnToCode #CodingTips
To view or add a comment, sign in
-
-
“How would you implement a word machine that processes a sequence of #stack operations, handles overflow/underflow, and returns errors for invalid states?” was my timed ⏳ #JavaScript coding task this morning. The description looked long, technical, and full of edge cases. It sounded abstract and … possibly even something I haven’t learned yet 👀 My palms got sweaty... still, instead of trying to “understand everything at once”, I forced myself to slow down and simplify it. At its core, the problem was just: array.push() array.pop() simple arithmetic (sum and subtract) That’s it. I simulated a stack (LIFO) using a simple #array, processed each operation sequentially, and validated the stack state before each operation. What looked like a complex system was really just a question of understanding the right #DataStructure. Once I managed to recognise it and apply it with discipline, everything else followed. #CodingChallenge #JuniorDeveloper #SoftwareEngineering
To view or add a comment, sign in
-
-
📌 #69 DailyLeetCodeDose Today's problem: 25. Reverse Nodes in k-Group – 👹 Hard Interesting fact about me – linked lists were my favorite topic in the Algorithms and Data Structures course at university. So for the 69th problem I got something special – a hard linked list problem 😈 Honestly, the problem description is written in probably the most confusing way possible. But the core idea is actually pretty simple: you just need to reverse nodes in groups of size k inside the list. In practice, this is only slightly more complicated than reversing the entire linked list – the main difference is that when you reverse a group, you must keep track of the new head of that reversed group so you can correctly reconnect it with the previous and next parts of the list. It may look scary at first glance, but in reality it's not that bad. The most important thing is not to get lost in pointer manipulation 🦍 https://lnkd.in/daAPrhbP #DailyLeetCodeDose #LeetCode #JavaScript #Algorithms #ProblemSolving #Coding
To view or add a comment, sign in
-
-
Sharing beginner-friendly notes on Advanced Functions in JavaScript 🧠 Covered two of the most important concepts every JS developer needs to master, Closures and Higher-Order Functions. The guide walks through how closures "remember" their lexical scope, enabling data privacy, memoization, and function factories. Also explored essential Higher-Order Functions like map, filter, reduce, and practical utilities like debounce, throttle, curry, and compose with clear examples and visual diagrams. A practical guide for understanding how functions truly work under the hood. Feedback and suggestions are welcome! #JavaScript #Coding #Learning #Programming
To view or add a comment, sign in
-
🚦 𝐋𝐞𝐭’𝐬 𝐚𝐝𝐝 𝐬𝐨𝐦𝐞 𝐥𝐨𝐠𝐢𝐜 𝐭𝐨 𝐭𝐡𝐚𝐭 𝐜𝐨𝐝𝐞! I’m excited to share the 3rd blog of my "JavaScript Essentials 101" series. After covering variables, data types and operators, it's time to learn how to guide your code through different paths. This time, we are diving deep into 𝐂𝐨𝐧𝐭𝐫𝐨𝐥 𝐅𝐥𝐨𝐰: 𝐈𝐟, 𝐄𝐥𝐬𝐞, 𝐚𝐧𝐝 𝐒𝐰𝐢𝐭𝐜𝐡. In my blog post, I breakdown exactly how JavaScript processes logic, using beginner-friendly examples that actually make sense. 𝐇𝐞𝐫𝐞 𝐢𝐬 𝐰𝐡𝐚𝐭 𝐰𝐞 𝐜𝐨𝐯𝐞𝐫: ✅ 𝐓𝐡𝐞 "𝐓𝐫𝐚𝐟𝐟𝐢𝐜 𝐑𝐮𝐥𝐞𝐬" 𝐨𝐟 𝐂𝐨𝐝𝐞: A simplified definition of what control flow actually means. ✅ 𝐈𝐟, 𝐄𝐥𝐬𝐞, 𝐚𝐧𝐝 𝐭𝐡𝐞 𝐋𝐚𝐝𝐝𝐞𝐫: Master foundational decision-making (using conditions like checking voting age or grading marks). ✅ 𝐓𝐡𝐞 𝐒𝐰𝐢𝐭𝐜𝐡 𝐒𝐭𝐚𝐭𝐞𝐦𝐞𝐧𝐭: How to use multi-way branching for cleaner, more readable alternatives to long else if chains. ✅ 𝐓𝐡𝐞 𝐁𝐫𝐞𝐚𝐤𝐢𝐧𝐠 𝐏𝐨𝐢𝐧𝐭: Why the break keyword is crucial inside switch. ✅ 𝐓𝐡𝐞 𝐆𝐨𝐥𝐝𝐞𝐧 𝐑𝐮𝐥𝐞: A practical breakdown of exactly when to use switch vs. if-else. Mastering these conditional structures is what transforms a simple "coder" into an "application builder." Stop letting your code run sequentially and start making it intelligent! 𝐑𝐞𝐚𝐝 𝐭𝐡𝐞 𝐟𝐮𝐥𝐥, 𝐝𝐞𝐭𝐚𝐢𝐥𝐞𝐝 𝐠𝐮𝐢𝐝𝐞 𝐡𝐞𝐫𝐞: https://lnkd.in/ghpw9iPc Mentions: Hitesh Choudhary Piyush Garg Chai Aur Code Akash Kadlag Jay Kadlag Suraj Kumar Jha Nikhil Rathore #JavaScript #CodingTips #WebDevelopment #LearnToCode #Programming #CodeLogic #Hashnode #ChaiAurCode #ChaiCode
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