✅ Day 70 of 100 Days LeetCode Challenge Problem: 🔹 #1051 – Height Checker 🔗 https://lnkd.in/g7bmj62W Learning Journey: 🔹 Today’s problem required identifying how many students are not standing in the correct order according to their heights. 🔹 I first created a sorted version of the heights array to represent the expected order. 🔹 Then I compared each element of the original list with the corresponding element in the sorted list. 🔹 Every mismatch indicates a student standing in the wrong position, so I incremented a counter for each difference. Concepts Used: 🔹 Sorting 🔹 Array Comparison 🔹 Iteration Key Insight: 🔹 Instead of rearranging elements, simply comparing the original array with its sorted version reveals how many indices differ. 🔹 Each mismatch directly contributes to the final count. Complexity: 🔹 Time: O(n log n) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
LeetCode Challenge Day 70: Height Checker Problem Solution
More Relevant Posts
-
🚀 #100DaysOfCode – Day 52 📌 Problem: Sort Colors (LeetCode 75) 💡 Problem Idea: You are given an array containing only 0s, 1s, and 2s, representing three colors. The task is to sort the array in-place so that all 0s come first, then 1s, and then 2s. ⚡ Key Insight: Instead of using a sorting algorithm, we can solve this in one pass using three pointers. We maintain three regions: Left pointer → position for next 0 Right pointer → position for next 2 Current pointer (i) → traverses the array 🎯 Approach (Dutch National Flag Algorithm): If element is 0 → swap with left, move both left and i If element is 1 → just move i If element is 2 → swap with right, decrease right 📈 Complexity: Time Complexity: O(n) Space Complexity: O(1) (in-place sorting) ✅ Efficient because the array is processed only once. 💭 Learning: This problem is a great example of how pointer techniques can optimize sorting problems without using built-in sort functions. #DSA #LeetCode #Python #CodingJourney #ProblemSolving #Algorithms #100DaysOfCode #LinkedInLearning
To view or add a comment, sign in
-
-
✅ Day 96 of 100 Days LeetCode Challenge Problem: 🔹 #2278 – Percentage of Letter in String 🔗 https://lnkd.in/g8fEbrKG Learning Journey: 🔹 Today’s problem focused on calculating the percentage of a specific character in a string. 🔹 I iterated through the string and counted how many times the given letter appears. 🔹 Simultaneously tracked the total length of the string. 🔹 Then computed the percentage using the formula: (count / length) * 100. 🔹 Used floor division (via math.floor) to round down the result to the nearest integer. Concepts Used: 🔹 String Traversal 🔹 Counting Frequency 🔹 Basic Math Computation 🔹 Floor Operation Key Insight: 🔹 The problem is straightforward counting, but careful handling of rounding is important. 🔹 Using a single pass keeps the solution efficient and clean. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
🚀 Day 16 – DSA Daily Series Today’s Problem: Two Sum II – Input Array Is Sorted (LeetCode 167) Today’s problem was simple yet really interesting — especially because of how efficiently it can be solved using the two-pointer technique. 🧠 Problem Given a sorted array, find two numbers such that they add up to a target value and return their indices (1-based). Example: Input: [2,7,11,15], target = 9 Output: [1,2] 💡 Approach Instead of using extra space like a hashmap, I used: • Two pointers — one at the start and one at the end • If sum is too large → move right pointer left • If sum is too small → move left pointer right • Stop when target is found Clean and efficient ⚡ ⏱ Complexity Time Complexity: O(n) Space Complexity: O(1) 🔎 Key Learning When the array is already sorted, always think of two pointers before anything else — it saves both time and space. Solved it today and it felt really smooth to implement! 💯 Continuing to stay consistent and improve step by step 🚀 #DSA #LeetCode #Python #TwoPointers #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
✅ Day 92 of 100 Days LeetCode Challenge Problem: 🔹 #2011 – Final Value of Variable After Performing Operations 🔗 https://lnkd.in/gX-JQNUJ Learning Journey: 🔹 Today’s problem was about evaluating a sequence of increment and decrement operations. 🔹 I initialized a variable ans = 0 to track the value. 🔹 Used a hashmap to map each operation to its effect: • "++X" and "X++" → +1 • "--X" and "X--" → -1 🔹 Iterated through the operations and updated ans accordingly. 🔹 Returned the final computed value. Concepts Used: 🔹 HashMap / Dictionary 🔹 String Matching 🔹 Simple Simulation Key Insight: 🔹 Instead of using multiple condition checks, mapping operations to values simplifies logic and improves readability. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
🚀 Day 11 – DSA Daily Series Today’s Problem: Find Minimum in Rotated Sorted Array (LeetCode 153) Today I solved an interesting problem that involves finding the minimum element in a rotated sorted array. 🧠 Problem You are given a sorted array that has been rotated several times. The task is to find the minimum element in the array. Example: Input: nums = [3,4,5,1,2] Output: 1 💡 Approach I solved this problem using Binary Search. Key idea: • In a rotated sorted array, the minimum element lies at the rotation point • Compare the middle element with the rightmost element • If nums[mid] > nums[high], the minimum lies in the right half • Otherwise, it lies in the left half including mid By narrowing the search space, we efficiently locate the minimum element. ⏱ Complexity Time Complexity: O(log n) Space Complexity: O(1) 🔎 Key Learning Binary Search can be extended beyond simple searching and used to identify structural properties of arrays like rotation points. Continuing the DSA Daily Series — solving and learning one problem at a time. 🚀 #DSA #LeetCode #Python #Algorithms #BinarySearch #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 12 of Consistency | #75DaysLeetCodeChallenge 🧠 Today’s Problem : 3Sum (#15) 💡 Key Learning: This problem teaches how to efficiently find triplets using sorting + two-pointer technique, while carefully handling duplicates. ⚡ Approach: Sort the array → fix one element (i) → use two pointers (l, r) → If sum == 0 → store triplet & skip duplicates If sum < 0 → move l++ If sum > 0 → move r-- 🧠 Why this works: Reduces complexity from O(n³) → O(n²) Avoids duplicate triplets Efficient use of sorting + two pointers 🔥 Result : ✔️ Runtime: 574 ms (Beats 75.21%) 📈 Problems like this build strong intuition for tackling complex array & pattern-based questions. Consistency is compounding. Keep going. 💪 #Day12 #LeetCode #DSA #CodingJourney #100DaysOfCode #Python #TwoPointers #Consistency
To view or add a comment, sign in
-
-
🚀Day-7 LeetCode Problem Solved – #3 Longest Substring Without Repeating Characters Today I solved one of the most popular Sliding Window problems on LeetCode: Longest Substring Without Repeating Characters 💡 Problem Summary: Given a string, find the length of the longest substring without any repeating characters. 🔍 Approach Used: I solved this using the Sliding Window + HashSet technique. The idea is to maintain a window of unique characters using two pointers: - left → start of the window - right → end of the window - set → stores current unique characters Whenever a duplicate character appears, I move the left pointer until the duplicate is removed, while continuously tracking the maximum length. ✨ Key Learning: This problem helped me strengthen my understanding of: - Sliding Window - Two Pointers - HashSet / Set operations - Time complexity optimization ⚡ Complexity: Time: O(n) Space: O(n) Every problem solved is one step closer to mastering DSA and problem-solving skills 💻 #LeetCode #DSA #Python #ProblemSolving #CodingJourney #SoftwareDeveloper #SlidingWindow #100DaysOfCode #InterviewPreparation
To view or add a comment, sign in
-
-
Just built an Interactive Quiz Game Pro using Python and Gradio. Features: Multiple difficulty levels Real-time feedback with explanations Performance analytics (Bar & Pie Charts) Leaderboard system And here’s something important — I built this entire project on Google Colab, not on a high-end machine. In today’s era, you don’t need a powerful computer to build powerful projects — you need knowledge, consistency, and the right tools. Keep learning. Keep building. #Python #Gradio #BuildInPublic #CodingJourney #Students #Tech #Learning
To view or add a comment, sign in
-
🚀 Day 51/200 – LeetCode Challenge Today’s problem: Island Perimeter 🌊🏝️ Focused on understanding how to efficiently calculate boundaries in a grid using a simple yet powerful observation: 👉 Each land cell contributes 4 edges 👉 Shared edges reduce the total perimeter 🔍 Key Takeaways: Learned to optimize by avoiding unnecessary checks Strengthened grid traversal and pattern recognition skills Practiced writing clean and efficient code 💡 Result: ✅ Accepted ⚡ Runtime: 38 ms 📊 Beat ~65% of submissions Consistency is the real game changer. Small improvements every day lead to big results over time. #Day51 #200DaysOfCode #LeetCode #Python #DataStructures #Algorithms #CodingJourney #Consistency
To view or add a comment, sign in
-
-
From “it works” to “it won’t break” While writing a code, Getting it to work is one thing, 𝗠𝗮𝗸𝗶𝗻𝗴 𝘀𝘂𝗿𝗲 𝗶𝘁 𝗱𝗼𝗲𝘀𝗻’𝘁 𝗯𝗿𝗲𝗮𝗸 is another. price = products["Laptop"] This works fine… until the 𝗸𝗲𝘆 𝗱𝗼𝗲𝘀𝗻’𝘁 𝗲𝘅𝗶𝘀𝘁 . That’s when the program crashes. So instead of assuming every piece of data is present, Its better to start thinking about what happens when it isn’t. In college projects, we often focus on making things work. In real-world scenarios, 𝗲𝗱𝗴𝗲 𝗰𝗮𝘀𝗲𝘀 matter just as much. 𝗗𝗮𝘆 𝟭𝟮/𝟯𝟬 #Python #LearningInPublic #Day12 #30DaysOfCode #SoftwareEngineering
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