Day 36 — #100DaysOfLeetCode 🚀 Problem: Average Salary Excluding the Minimum and Maximum Salary (LeetCode 1491) ✅ Approach: Remove min & max, then calculate the average of remaining elements. ⚡ Complexity: O(n) Learning: Practiced clean logic writing and handling edge cases with arrays 🔥 #LeetCode #100DaysOfCode #DSA #Arrays #ProblemSolving #CodingJourney
Solved LeetCode 1491: Average Salary Excluding Min and Max
More Relevant Posts
-
Day 22 of #100DaysOfCode Today I solved the “Permutation in String” problem on LeetCode — a tricky one that really sharpens your understanding of sliding window and frequency mapping in strings. 🧩 Problem in short: Given two strings s1 and s2, the task is to check if any permutation of s1 exists as a substring in s2. At first glance, it feels like a brute-force problem — generate all permutations of s1 and check each in s2. But that’s computational suicide for longer strings. So the challenge was to find a smarter, optimized approach. ⚙️ Intuitive Approach: Instead of generating permutations, I focused on character frequencies. Maintain two frequency arrays — one for s1 and one for the current window of s2. Slide the window across s2, adding and removing characters as you move. Whenever both frequency arrays match, it means that substring of s2 is a permutation of s1. This approach reduces the complexity drastically and relies on pattern recognition through frequency matching, not brute force. Every day in this challenge is a reminder that optimization isn’t about doing less work — it’s about doing the right work. #LeetCode #C++ #ProblemSolving #DSA #CodingJourney #100DaysOfCode
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
-
-
Day 47 — #100DaysOfLeetCode 🚀 Problem: Reverse Words in a String (LeetCode 151) ✅ Approach: Trim spaces, split the string, reverse the words, and join them back. ⚡ Complexity: O(n) Learning: Improved string handling and manipulation efficiency 🔁 Every line of code adds clarity and confidence 💪 #LeetCode #100DaysOfCode #DSA #Strings #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 46 — #100DaysOfLeetCode 🚀 Problem: Remove Duplicate Letters (LeetCode 316) ✅ Approach: Used a Stack + Greedy approach to build the smallest lexicographical string with unique letters. ⚡ Complexity: O(n) Learning: Strengthened understanding of stack-based string manipulation and greedy logic 🔠 #LeetCode #100DaysOfCode #DSA #Strings #Stack #GreedyAlgorithm #ProblemSolving #CodingJourney
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
-
-
💡 Day 35 of 100 — Minimum One Bit Operations to Make Integers Zero (#LeetCode 1611) Today’s problem was short, elegant, and surprisingly deep. At first glance, it looks like a simple bit manipulation task but under the hood, it’s built on some beautiful binary mathematics. 🧠 What I figured out The problem is all about understanding how Gray codes work a sequence where only one bit changes between consecutive numbers. The key trick? Using bitwise XOR iteratively to simulate these transitions until the number becomes zero. It’s one of those problems where the solution is just a few lines, but the concept behind it is worth hours of thought. 💻 My thought process Initially, I tried to think recursively flipping bits one by one but it got confusing fast. Then I realized the XOR pattern behaves exactly like the transformation sequence itself. Just keep XORing the number with itself as it right-shifts, and you end up with the minimal operations needed. 📊 Complexity: Time — O(log n) Space — O(1) 💬 Reflection This problem was a great reminder that simplicity can hide elegance. Just a few XORs and suddenly, something that felt complex becomes almost poetic in logic. #100DaysOfLeetCode #Day35 #LeetCodeJourney #DSA #Python
To view or add a comment, sign in
-
-
🌿Day 73 LeetCode: Next Greater Element I (496) Approach: Used a stack to find the next greater element for each number in nums2 and stored results in a hash map for quick lookup in nums1. ✨ Learned how to use monotonic stacks for next-greater problems — a smart way to reduce time complexity and strengthen logic! 📈 Improved understanding of stacks, hash maps, and element mapping techniques in C++. #LeetCode #100DaysOfCode #DSA #Stack #HashMap #Arrays #ProblemSolving #CodingJourney #CodeEveryday
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 105 of 365 of Solving LeetCode Problems! ✅ Generate All Binary Strings: Given an integer n, generate all binary strings of length n representing bits. Return the strings in ascending order. Key Observations: 1) This is a classic recursion and backtracking problem — each position can either be '0' or '1'. 2) You explore both possibilities recursively until the string reaches length n. 3) The order of recursive calls ('0' first, then '1') ensures the results are in lexicographical (ascending) order. 4) Time complexity is O(2^n) since there are 2^n possible binary strings. #Recursion #Backtracking #LeetCode #DSA
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