Why everything looks correct isn't enough ? I was solving a leetcode problem today.I thought I had it all figured out because the logic was perfect and it worked on almost every test case. I converted the array elements into a number, manipulated it, and then converted back. On paper, it seemed fine until a few edge test cases failed. The reason was integer overflow. My "correct" solution was fundamentally flawed. #DSA #LeetCode #CodingLessons #ProblemSolving #Programming #LessonLearnt
Gautam Sihag’s Post
More Relevant Posts
-
Solved “Binary Tree Preorder Traversal” on LeetCode today using an iterative approach in C++. Key focus areas: Stack-based traversal instead of recursion Optimizing traversal order (push right child first, then left) Clean handling of edge cases (null root) Result: 100% runtime performance Efficient memory usage #LeetCode #DataStructures #Algorithms #DSA #BinaryTree #TreeTraversal #Cpp #Programming #SoftwareDevelopment #CodingJourney #ProblemSolving #ComputerScience #DeveloperGrowth
To view or add a comment, sign in
-
-
🚀 Implemented Insertion Sort today! It sorts the array by picking an element and inserting it into its correct position in the sorted part. 💻 Simple logic, great for small or nearly sorted data. Time Complexity: O(n²) #InsertionSort #DSA #Coding #Programming
To view or add a comment, sign in
-
I wrote a beginner-friendly article explaining 10 Pattern Problems in C++ with diagrams and code. Pattern problems are a great way to improve logic and understanding of loops. Check it out here: https://lnkd.in/grVA7Ggb #Programming #CPP #Coding
To view or add a comment, sign in
-
-
Design HashSet: https://lnkd.in/gAJKquxc My Solution: Time Complexity: O(N) --Worst Case Space Complexity: O(N) Can be improved with Rehashing #LeetCode #DSA #ProblemSolving #CPP #Programming #Coding #Solution #Hashing #LinkedList
To view or add a comment, sign in
-
-
DAY->12 Solved Running Sum of 1d Array on LeetCode today. Implemented the solution using the Prefix Sum technique to compute the cumulative sum of elements efficiently. -> Time Complexity: O(n) -> Space Complexity: O(n) All 54/54 test cases passed with 0 ms runtime. Small problems like this help strengthen fundamentals in arrays and prefix sums, which are widely used in many algorithmic problems. #LeetCode #DSA #CodingJourney #Programming #Cplusplus #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 13/60 — LeetCode Discipline Problem Solved: Contains Duplicate II (Revision) Difficulty: Easy Today’s practice focused on revisiting a classic array problem that blends hashing with a sliding window concept. The goal was to efficiently determine whether duplicate values appear within a specific index range. Instead of checking every possible pair, the approach maintains a moving window of elements using a hash structure, allowing constant-time lookups while traversing the array. 💡 Focus Areas: • Reinforced hash-based lookup techniques • Practiced sliding window with bounded size • Strengthened index-distance reasoning • Improved understanding of time-efficient duplicate detection • Focused on clean and readable implementation Even simple problems can reinforce powerful ideas when approached with discipline and clarity. #LeetCode #60DaysOfCode #100DaysOfCode #DSA #SlidingWindow #HashSet #Arrays #Algorithms #DataStructures #ProblemSolving #CodingJourney #SoftwareEngineering #Programming #Developers
To view or add a comment, sign in
-
-
They said it couldn't be tested... But they were wrong. Sort of. We're done with excuses! No more claims that when dealing with legacy code your changes can't be tested. We're drawing the line now. It's true that some code really just doesn't lend itself well to being tested. There's no denying that! But what if we could guarantee that every time we touched some code, even in the most untestable places, that we could do *SOMETHING* that added a bit more test coverage to build confidence? Check out the article: https://lnkd.in/ggK-8ECr #legacycode #testing #programming #coding
To view or add a comment, sign in
-
-
Every developer has experienced this. You spend hours debugging your code, checking every function, rewriting logic… and the real problem ends up being a tiny mistake. Sometimes the biggest lessons in programming come from the smallest bugs. Read the story: https://lnkd.in/dTF-2uV7 #programming #webdevelopment #coding #softwareengineering
To view or add a comment, sign in
-
-
Have you heard of inversion of control? So what the heck is "Inversion of Control" (IoC)? It's got a fancy name, but what exactly are we inverting? No, we're not going to be writing code upside down. Although, that could be fun. Instead, the concept will be moving the responsibilities of something back out to the caller or creator. If that sounds weird, it's because it's a bit of a paradigm shift. Something like dependency injection is a great practical example of IoC! Check out the article: https://lnkd.in/g9kjUmsN #programming #coding
To view or add a comment, sign in
-
-
Leetcode POTD: Sort Integers by the Number of 1 Bits Today’s POTD was so easy 😄 if you know about built-in popcount and how to write a custom comparator. Intuition: LeetCode is focusing a lot on binary these days, so it was pretty intuitive to use built-in popcount 💡 Count set bits, sort based on that, and if bits are same -> sort in ascending order Attached my notes for reference ✍️ #leetcode #potd #consistency #programming #binary #bitManipulation
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