✅ Day 62 of 100 Days LeetCode Challenge Problem: 🔹 #807 – Max Increase to Keep City Skyline 🔗 https://lnkd.in/gKESivus Learning Journey: 🔹 Today’s problem focused on increasing building heights without altering the city skyline from top and side views. 🔹 I computed the maximum height for each row (left/right skyline) and each column (top/bottom skyline). 🔹 For every cell, the allowed maximum height is min(rowMax[i], colMax[j]). 🔹 The total increase is the sum of differences between the allowed height and the current height. Concepts Used: 🔹 Matrix Traversal 🔹 Row and Column Preprocessing 🔹 Greedy Height Adjustment 🔹 Boundary Constraints Key Insight: 🔹 The skyline constraint limits each building by both its row and column maximums. 🔹 Taking the minimum of row and column caps preserves visibility constraints. 🔹 Precomputing row and column maximums reduces redundant computation and keeps the solution efficient at O(m x n). #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
Max Increase to Keep City Skyline LeetCode Challenge
More Relevant Posts
-
Just solved “Longer Contiguous Segments of Ones than Zeros” on LeetCode with 0 ms runtime ⚡ Instead of storing segments or using extra space, I approached it with a single pass linear scan. 💡 My approach: Maintain two counters: count_1 → current streak of 1s count_0 → current streak of 0s Maintain two variables: maximum_1 → longest contiguous 1s maximum_0 → longest contiguous 0s While iterating through the string: If the character is '1', increase count_1 and reset count_0 If the character is '0', increase count_0 and reset count_1 Continuously update the maximum streaks Finally check if max(1s) > max(0s) ✨ Why this works well Only one traversal O(n) time complexity O(1) space complexity Clean and simple logic Always fascinating how simple state tracking can solve problems efficiently. Back to solving more problems and sharpening problem-solving skills! 🔥 #leetcode #coding #datastructures #algorithms #programming #python #codingpractice #problemSolving #softwareengineering #techlearning #computerscience #developers #100daysofcode #codingjourney #womenintech 🚀
To view or add a comment, sign in
-
-
✅ Day 63 of 100 Days LeetCode Challenge Problem: 🔹 #1758 – Minimum Changes To Make Alternating Binary String 🔗 https://lnkd.in/gSY9BDhw Learning Journey: 🔹 Today’s problem focused on converting a binary string into an alternating pattern with minimum changes. 🔹 There are only two valid alternating patterns: starting with '0' (0101...) or starting with '1' (1010...). 🔹 I counted mismatches for both patterns while iterating through the string. 🔹 The answer is the minimum number of flips required between the two possibilities. Concepts Used: 🔹 String Traversal 🔹 Pattern Matching 🔹 Greedy Counting 🔹 Parity Indexing Key Insight: 🔹 When only two structural patterns are possible, evaluate both and choose the minimum cost. 🔹 Index parity (i % 2) is a clean way to enforce alternating constraints. 🔹 Comparing against expected patterns avoids unnecessary string reconstruction. #LeetCode #DataStructures #Algorithms #CodingInterview #SoftwareEngineering #SoftwareDeveloper #ProblemSolving #Programming #ComputerScience #TechCareers #100DaysOfCode #DailyCoding #Consistency #LearningInPublic #Python #BackendDevelopment #InterviewPreparation #TechCommunity
To view or add a comment, sign in
-
-
✅ Day 80 of 100 Days LeetCode Challenge Problem: 🔹 #3876 – Construct Uniform Parity Array II 🔗 https://lnkd.in/gENuCXJc Learning Journey: 🔹 Today’s problem focused on determining whether we can construct an array where all elements are either all even or all odd using allowed operations. 🔹 The key observation was around parity (odd/even nature) of numbers. 🔹 Since we can subtract elements, the parity depends on whether differences can produce consistent odd or even values. 🔹 I simplified the logic by checking: • If the minimum element is odd → we can make all elements odd • Otherwise, verify if all elements are already even Concepts Used: 🔹 Parity (Odd/Even Analysis) 🔹 Mathematical Observation 🔹 Greedy Logic Key Insight: 🔹 Subtracting numbers preserves or changes parity in predictable ways. 🔹 The smallest element plays a crucial role in determining whether all elements can be transformed into the same parity. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
Day 44 of #GeekStreak60: Math Makes Algorithms Beautiful! 🧮💻 Tackled the "Partitions with Given Difference" problem on @GeeksforGeeks today. Key Learning: Sometimes the best way to solve a complex coding problem is to not code at all, just use algebra! The problem asked to find two subsets where S1 - S2 = diff. Since we also know that S1 + S2 = total_sum, adding the equations together reveals that S1 = (total_sum + diff) / 2. Just like that, a complex two-subset balancing problem collapsed into a standard 0/1 Knapsack "Subset Sum" problem! I implemented a space-optimized 1D Dynamic Programming array to count the subset combinations, achieving the solution in pure O(n x sum) time. Reducing unfamiliar problems down to known architectural patterns is the ultimate problem-solving hack. 🚀 #geekstreak60 #npci #coding #Algorithms #Python #DataStructures #DynamicProgramming #Mathematics #ProblemSolving
To view or add a comment, sign in
-
-
✅ Day 81 of 100 Days LeetCode Challenge Problem: 🔹 #1897 – Redistribute Characters to Make All Strings Equal 🔗 https://lnkd.in/gZ7wZ7JE Learning Journey: 🔹 Today’s problem required checking if we can redistribute characters so that all strings become identical. 🔹 I combined all strings and used a frequency counter to count occurrences of each character. 🔹 Since we can freely move characters between strings, the only requirement is that each character count must be divisible by the number of strings. 🔹 If any character fails this condition, it’s impossible to evenly distribute it. Concepts Used: 🔹 Hash Map / Frequency Counting (Counter) 🔹 String Concatenation 🔹 Divisibility Check Key Insight: 🔹 The exact arrangement doesn’t matter—only the total frequency distribution matters. 🔹 If every character can be equally divided among all strings, a valid configuration always exists. Complexity: 🔹 Time: O(n * k) (n = number of strings, k = average length) 🔹 Space: O(1) (bounded by alphabet size) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
✅ Day 88 of 100 Days LeetCode Challenge Problem: 🔹 #1252 – Cells with Odd Values in a Matrix 🔗 https://lnkd.in/g5eE9A-e Learning Journey: 🔹 Today’s problem focused on simulating row and column increment operations on a matrix. 🔹 I initialized an m × n matrix with all zeros. 🔹 For each index [ri, ci], I incremented: • All elements in row ri • All elements in column ci 🔹 After applying all operations, I traversed the matrix to count how many cells contain odd values. Concepts Used: 🔹 Matrix Simulation 🔹 Nested Loops 🔹 Conditional Counting 🔹 Basic Array Manipulation Key Insight: 🔹 Direct simulation works efficiently due to small constraints. 🔹 Each operation affects an entire row and column, so tracking increments carefully is key. Complexity: 🔹 Time: O(m × n + k × (m + n)) 🔹 Space: O(m × n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
✅ Day 89 of 100 Days LeetCode Challenge Problem: 🔹 #1480 – Running Sum of 1D Array 🔗 https://lnkd.in/gSTZrxF7 Learning Journey: 🔹 Today’s problem focused on computing the running (prefix) sum of an array. 🔹 Instead of using an extra array, I optimized the solution by modifying the input array in-place. 🔹 Starting from index 1, I updated each element as: • nums[i] += nums[i-1] 🔹 This way, each index stores the cumulative sum up to that point. 🔹 Finally, returned the modified array. Concepts Used: 🔹 Prefix Sum 🔹 In-place Computation 🔹 Array Traversal Key Insight: 🔹 The previous element already stores the prefix sum, so we can reuse it directly. 🔹 Eliminates the need for extra space while maintaining linear time. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
#Today’sFocus: Circular Linked List 🔄 Today I explored Circular Linked Lists (CLL) and implemented two fundamental operations: Creation and Display. Unlike traditional linked lists, a Circular Linked List connects the last node back to the first node, forming a loop 🔁 This means there is no NULL pointer — traversal can continue endlessly! 🔍 What I Practiced: 🔸 Creation of Circular Linked List → Created nodes dynamically → Linked each node sequentially → Connected last node back to head 🔸 Display Operation → Started traversal from head → Used loop to stop when reaching head again → Ensured no infinite loop ⚠️ 💡 Key Insight: Handling traversal in CLL requires careful stopping conditions — since there is no NULL, we must detect when we return to the starting node. 🎯 Why This Matters: ✔ Efficient round-robin scheduling ✔ Multiplayer gaming loops 🎮 ✔ Circular queues ✔ Continuous data processing systems #DataStructures #LinkedList #CircularLinkedList #DSA #Algorithms #Programming #Coding #SoftwareEngineering #ComputerScience #Python #LearnToCode #CodingJourney #TechSkills
To view or add a comment, sign in
-
-
✅ Day 72 of 100 Days LeetCode Challenge Problem: 🔹 #3868 – Minimum Cost to Equalize Arrays Using Swaps 🔗 https://lnkd.in/gwbcmecy Learning Journey: 🔹 Today’s problem involved making two arrays identical with the minimum number of cross-array swaps. 🔹 Swapping within the same array is free, but swapping elements between arrays costs 1 operation. 🔹 I used Counter to count the frequency of elements in both arrays. 🔹 Then I combined the counters to check the total occurrences of each element. 🔹 If any element has an odd total frequency, it’s impossible to distribute it equally between both arrays. 🔹 Otherwise, I calculated the difference in counts between the two arrays to determine how many elements must be swapped. Concepts Used: 🔹 Frequency Counting (Counter) 🔹 Hash Maps 🔹 Greedy Counting Logic 🔹 Swap Balancing Key Insight: 🔹 For the arrays to become identical, every element must appear an even number of times across both arrays. 🔹 The imbalance of each element indicates how many swaps are required, and dividing appropriately accounts for pairwise swaps. Complexity: 🔹 Time: O(n) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
You can use data for better understanding the reality. By highlighting where cars are accelerating or slowing down, traffic can be optimized and this needs just a camera. This is one of the possible applications of speedcam. A python package I am developing for vehicle speed estimation, heatmaps, and traffic flow counting from a video stream. It can be used with RF-DETR or YOLO architecture and it can be easily plugged in your workflow. You will find all the details on the repository readme, check the first comment. #computervision #ai #python
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