🔢 Day 69 of #100DaysOfCode 🔢 🔹 Problem: Maximum Count of Positive and Negative Integers – LeetCode ✨ Approach: A simple yet powerful one-pass solution! Iterated through the array, counting positives and negatives separately — and returned whichever count was greater. Clean, direct, and efficient. ⚡ 📊 Complexity Analysis: Time Complexity: O(n) — single traversal of the array Space Complexity: O(1) — no extra data structures used ✅ Runtime: 1 ms (Beats 12.27%) ✅ Memory: 46.89 MB 🔑 Key Insight: Sometimes, simplicity wins — clarity in logic often outperforms complex tricks. Counting right leads to coding right! 💡 #LeetCode #100DaysOfCode #ProblemSolving #DSA #Array #AlgorithmDesign #LogicBuilding #CodeJourney #ProgrammingChallenge #CodingDaily #Efficiency
Solved LeetCode problem with simple counting approach in 69 days
More Relevant Posts
-
💡 Day 78 of #100DaysOfCode 💡 🔹 Problem: Find Closest Number to Zero – LeetCode ✨ Approach: Traversed through the array while keeping track of the number closest to zero using absolute difference comparison. Handled ties by preferring the positive number — because even in code, positivity wins 😉 📊 Complexity Analysis: ⏱ Time Complexity: O(n) — single pass through the array 💾 Space Complexity: O(1) — no extra space used ✅ Runtime: 3 ms (Beats 44.80%) ✅ Memory: 46.87 MB 🔑 Key Insight: Even the smallest differences matter — especially when you’re finding what’s closest to zero! ⚡ #LeetCode #100DaysOfCode #DSA #ProblemSolving #CodingChallenge #JavaProgramming #AlgorithmDesign #CodeJourney #StayPositive
To view or add a comment, sign in
-
-
🚀 Day 7 of #120DaysOfCode Challenge 💡 Problem: Reverse Integer (LeetCode #7 | Medium) 📄 Problem Statement: Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes it to go outside the signed 32-bit integer range [-2³¹, 2³¹ - 1], then return 0. 🧩 My Approach: Extract the last digit of x using % 10. Build the reversed number step by step using rev = rev * 10 + digit. Carefully check for overflow before multiplying or adding — using INT_MAX and INT_MIN limits to ensure the reversed number stays valid. If overflow is detected, return 0. 🔍 Key Learnings: How to handle integer overflow without using 64-bit variables. Importance of edge case testing and boundary conditions. Reinforced understanding of modulus (%) and integer division (/) operations. 🔥 Progress: Day 7 / 120 📚 Language: C 🏁 Problem Solved: Reverse Integer (LeetCode #7) Every problem is a small step toward stronger logic and cleaner code! 💪 #100DaysOfCode #120DaysOfCode #CodingChallenge #LeetCode #CProgramming #ProblemSolving #LearnEveryday #BuildInPublic
To view or add a comment, sign in
-
-
🎯 Day 83 of #100DaysOfCode 🔹 Problem: Count the Digits That Divide a Number – LeetCode ✨ Approach: A simple yet elegant digit-based problem! I extracted each digit of the number using modulo and division, then checked whether the digit cleanly divides the original number. Every valid digit increases the count — a perfect use-case for number breakdown and modular arithmetic. 🔢⚡ 📊 Complexity Analysis: ⏱ Time Complexity: O(d) — where d is the number of digits 💾 Space Complexity: O(1) — no extra data structures used ✅ Runtime: 0 ms (Beats 100% 🚀) ✅ Memory: 42.29 MB 🔑 Key Insight: Even basic problems sharpen precision — breaking numbers digit-by-digit reinforces strong logical thinking and clean coding habits. Sometimes the simplest loops teach the most. ✨ #LeetCode #100DaysOfCode #DSA #NumberTheory #ModularArithmetic #CleanCode #EfficientCoding #LogicBuilding #TechJourney #ProgrammingChallenge #CodingDaily
To view or add a comment, sign in
-
-
I recently tackled LeetCode 2654 – Minimum Number of Operations to Make All Array Elements Equal to 1. Most solutions simulate every operation. The approach that worked for me came from stepping back and thinking mathematically: 1️⃣ If there’s already a 1 in the array, it can be spread to all other elements efficiently. 2️⃣ If no 1 exists, find the shortest subarray whose GCD is 1 – creating a 1 from that subarray is the minimal first step. 3️⃣ Once a 1 exists, the rest follows in a straightforward way. It’s a reminder that sometimes understanding the structure of a problem beats brute-force coding. And here’s a little validation: ✅ Runtime: 1ms, beats 100% of submissions ✅ Memory: 56.1MB, beats 100% of submissions For anyone doing coding challenges or preparing for interviews, focus on insights like these – they often save more time than writing extra lines of code. #ProblemSolving #Algorithms #CodingMindset #LeetCode #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 80 of #100DaysOfCode 🚀 🧩 Problem: Merge Sorted Array — LeetCode 💡 Approach: Started from the end of both arrays, comparing elements and placing the larger one at the last position. This in-place merging avoids extra space and ensures efficiency — a clean, optimal two-pointer solution! ⚡ 📊 Complexity Analysis: ⏱ Time Complexity: O(m + n) 💾 Space Complexity: O(1) ✅ Runtime: 0 ms (Beats 100% 🚀) ✅ Memory: 43.82 MB ✨ Key Insight: Sometimes, the best way forward is to start from the end — both in arrays and in problem-solving. 😉 #LeetCode #100DaysOfCode #JavaProgramming #ProblemSolving #DSA #CodingChallenge #AlgorithmDesign #TechJourney #CodeEveryday
To view or add a comment, sign in
-
-
🌟 Day 71 of #100DaysOfCode 🌟 💡 Problem: Matrix Diagonal Sum – LeetCode ✨ Approach: Traversed both primary and secondary diagonals in a single loop — adding elements smartly while avoiding double-counting the center in odd-sized matrices. Simple logic, elegant optimization! ⚡ 📊 Complexity Analysis: Time Complexity: O(n) — single traversal through the matrix rows Space Complexity: O(1) — constant auxiliary space ✅ Runtime: 0 ms (Beats 100%🔥) ✅ Memory: 46.26 MB 🔑 Key Insight: In coding, clarity wins. The shortest paths often come from the clearest logic. 🎯 #LeetCode #100DaysOfCode #ProblemSolving #DSA #AlgorithmDesign #ProgrammingChallenge #CodeJourney #LogicBuilding #Efficiency #DeveloperGrowth #CodingDaily
To view or add a comment, sign in
-
-
🎯 Day 81 of #100DaysOfCode 🎯 🔹 Problem: Reverse Only Letters – LeetCode ✨ Approach: Used a two-pointer strategy to reverse only the alphabetic characters while keeping all non-letter characters in their original positions. By moving pointers inward and swapping only when both characters are letters, the solution stays efficient and elegant! 🔄✨ 📊 Complexity Analysis: ⏱ Time Complexity: O(n) — each character visited at most once 💾 Space Complexity: O(n) — due to character array construction ✅ Runtime: 0 ms (Beats 100% 🚀) ✅ Memory: 42.96 MB 🔑 Key Insight: Sometimes, all you need is smart pointer movement — not everything needs to be reversed, only the right pieces. #LeetCode #100DaysOfCode #DSA #TwoPointers #StringManipulation #ProblemSolving #CleanCode #AlgorithmDesign #CodingChallenge
To view or add a comment, sign in
-
-
🚀 Day 37 of #100DaysOfCode Challenge 🚀 🧠 Problem: 🧩 LeetCode 282 — Expression Add Operators (Hard) This problem was all about exploring backtracking with arithmetic logic. We’re given a string of digits and need to insert +, -, or * between them to reach a target value. ⚙️ Approach Used backtracking to: -Pick every possible substring as the next number. -Try adding each operator before it (+, -, *). -Track three things: -current value → total so far -previous operand → to handle multiplication correctly -expression → the string we’re building -Also skipped invalid paths like numbers with leading zeros. 📘 Learning -Understood how to evaluate expressions on the fly without using eval(). -Learned to manage operator precedence (* before +/-) using recursion and previous operand adjustment. -Realized that some problems can’t be optimized further — they test how well you can prune and organize recursion. #100DaysOfCode #DSA #CodingChallenge #StriversSheet #ProblemSolving #TakeUForward #Recursion #CodingInterview #ProgrammingTips #LeetCode #Backtracking
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