🧩 Day 38 / 100 – Transpose Matrix (LeetCode #867) Today’s problem focused on understanding matrix manipulation — specifically, the Transpose of a matrix. Transposing means flipping a matrix over its diagonal, turning rows into columns and columns into rows. It’s a simple concept but helps strengthen 2D array traversal logic — especially how to navigate nested loops cleanly and avoid index confusion. This was a good reminder that clarity and structure matter just as much as complexity. 🔍 Key Learnings Transposing a matrix means swapping element positions — matrix[i][j] → result[j][i]. Use nested loops efficiently to fill the new matrix with swapped indices. Always keep track of dimensions — rows become columns and vice versa. 💭 Thought of the Day Even small transformations like a transpose can teach big lessons in clean logic. Sometimes we overthink “hard” problems, but mastering basics like matrix traversal builds the foundation for solving advanced ones like rotation or dynamic programming grids. 🔗 Problem Link:https://lnkd.in/gHKB9h4b #100DaysOfCode #Day38 #LeetCode #Python #Matrix #Transpose #ProblemSolving #Algorithms #DataStructures #CodingChallenge #CodeEveryday #LearningJourney #CleanCode #TechGrowth #PythonProgramming
Transpose Matrix LeetCode #867: Simple yet powerful concept for 2D arrays
More Relevant Posts
-
👇 🚀 LeetCode Problem: String to Integer (atoi) 📘 Problem #8 | Medium Level 🧠 Concept: This problem is all about manually converting a string into an integer, similar to how the C/C++ atoi() function works — but with extra rules for spaces, signs, and number limits. 💡 Key Steps to Solve: Trim spaces – Ignore any leading whitespace. Check the sign – Identify if the number is positive or negative (+ / -). Extract digits – Read characters until a non-digit appears. Handle overflow – Clamp results within 32-bit signed integer range: Minimum: -2³¹ = -2147483648 Maximum: 2³¹ - 1 = 2147483647 Return the result – Considering the sign and bounds. 🧩 Example: Input: " -42" Output: -42 Input: "4193 with words" Output: 4193 Input: "-91283472332" Output: -2147483648 🔥 Takeaway: This challenge strengthens your understanding of: String parsing Edge case handling Integer overflow prevention #LeetCode #Coding #Python #ProblemSolving #Atoi #StringToInteger #DataStructures #Algorithms #100DaysOfCode
To view or add a comment, sign in
-
-
Day 33 / 100 – Maximum Average Subarray (LeetCode #643) Today’s challenge was about finding a contiguous subarray of length k with the maximum average. At first glance, it seems simple, but the key is doing it efficiently. By using a sliding window, I avoided recalculating sums for every subarray, which makes the solution both fast and elegant. This problem reminded me that small optimizations in logic can lead to huge improvements in performance, and thinking carefully about how to structure your solution is just as important as solving the problem itself. 🔍 Key Learnings Sliding window technique updates the sum in constant time for each step. Keeping track of the maximum sum while iterating avoids unnecessary computations. Always ensure floating-point division for correct average calculations. 💭 Thought of the Day Efficiency in coding comes from thinking smart, not from brute force. Sliding window allowed me to write clean and readable solutions while handling all edge cases. Today reinforced that solving problems isn’t just about getting a correct answer — it’s about writing solutions that are elegant, efficient, and scalable. 🔗 Problem Link:https://lnkd.in/gCVb4_pu #100DaysOfCode #Day33 #LeetCode #Python #SlidingWindow #ProblemSolving #Algorithms #DataStructures #CodingChallenge #CodeEveryday #LearningJourney #TechGrowth #Efficiency #CleanCode #PythonProgramming
To view or add a comment, sign in
-
-
🚀 DSA Progress – Day 117 ✅ Problem #946: Validate Stack Sequences 🧠 Difficulty: Medium | Topics: Stack, Simulation, Array 🔍 Approach: Implemented a stack-based simulation to validate push and pop sequences: Step 1 (Initialization): Create an empty stack st and pointers i and j for pushed and popped arrays. Step 2 (Push Elements): Iterate through pushed, pushing each element onto the stack. Step 3 (Pop Check): After each push, check if the top of the stack matches popped[j]. While the stack is not empty and top matches popped[j], pop from the stack and increment j. Step 4 (Final Validation): After processing all elements, if the stack is empty, the sequences are valid; otherwise, they are invalid. This approach simulates the real stack behavior step by step, ensuring that push/pop operations match the given sequences. 🕒 Time: O(n), each element is pushed and popped at most once. 💾 Space: O(n), for the stack. 📁 File: https://lnkd.in/gJJBfAjc 📚 Repo: https://lnkd.in/g8Cn-EwH 💡 Learned: This problem demonstrates how to simulate stack operations efficiently. It reinforced understanding of stack behavior and pointer manipulation. Using a simple stack and two pointers made the solution clean and intuitive. ✅ Day 117 complete — mastered the art of validating stack choreography! 🧩📦✨ #LeetCode #DSA #Python #Stack #Simulation #Array #DailyCoding #InterviewPrep #GitHubJourney
To view or add a comment, sign in
-
🚀 Day 42 of #100DaysOfCode — Leetcode + HackerRank Edition! Today’s challenge was a deep dive into string-based arithmetic — no shortcuts allowed! 🧩 multiply(num1: str, num2: str) -> str — Multiply two non-negative integers represented as strings, without using int() or BigInteger. 📌 Challenge: → No built-in conversion from string to integer → No BigInteger libraries → Just pure digit-by-digit simulation, like manual multiplication → Example: num1 = "123", num2 = "456" ✅ Output: "56088" 🔍 Approach: → Reversed both strings to simplify digit placement → Used ASCII math: ord(char) - ord('0') to extract digits → Stored intermediate products in an array of size len(num1) + len(num2) → Managed carry manually and built the final string from the result array 💡 What made it click: → Realized that each digit product lands at position i + j in the result array → Practiced dry runs to visualize how "123" * "456" becomes "56088" → Saw how carry propagation works across the array → Appreciated how reversing strings simplifies index math 📚 What I learned: ✅ How to simulate arithmetic without integer conversion ✅ How to use ASCII tricks to decode digits ✅ How to manage carry and build results step-by-step ✅ The power of dry runs to debug and understand logic Have you ever built a calculator or tackled string-based math problems? Let’s swap strategies and visual walkthroughs 💬 #Day42 #Leetcode #Python #StringManipulation #ASCIITricks #LearnInPublic #CodeNewbie #TechJourney #100DaysOfCode #DSA
To view or add a comment, sign in
-
-
🧩 Day 37 — Sqrt(x) (LeetCode 69) 📝 Problem -Given a non-negative integer x, return the square root of x rounded down to the nearest integer. -The returned integer should be non-negative. -You must not use any built-in exponent function or operator (e.g., pow(x, 0.5) or x ** 0.5). 🔁 Approach -Use binary search between 0 and x to find the integer square root. -At each step: -Calculate the midpoint m = l + (r - l) // 2. -If m² is greater than x, search in the left half. -If m² is less than x, move to the right half and record m as a possible answer. -If m² equals x, return m directly. -When the loop ends, res will hold the floor value of the square root. 📊 Complexity -Time Complexity: O(log x) -Space Complexity: O(1) 🔑 Concepts Practiced -Binary search on number range -Integer floor computation -Avoiding built-in power or square root functions #Leetcode #Python #DSA #Math #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Product of Array Except Self — LeetCode #238 Today, I solved one of the most elegant problems in array manipulation — “Product of Array Except Self.” 🧩 Problem in short: Given an integer array nums, return an array answer such that answer[i] equals the product of all numbers in nums except nums[i], ✅ Without using division ✅ In O(n) time ✅ With O(1) extra space 💡 Key Insight — Prefix & Suffix Products Instead of recalculating every product, the trick is to use two passes: First pass: Store the product of all elements before each index (prefix). Second pass: Multiply each element by the product of all elements after it (suffix). This way, each position in the output represents the product of all other elements — efficiently and elegantly. ⚙️ Complexity Time: O(n) Space: O(1) (excluding the result array) 📊 Result ✅ Accepted — Runtime: 20 ms ⚡ Beats 74.21% in performance and 55.22% in memory usage Every problem like this reinforces one key principle: In interviews (and real-world problems), pattern recognition always beats rote memorization. This one beautifully highlights the Prefix–Suffix Pattern, seen in problems like Trapping Rain Water and Subarray Product. #LeetCode #DSA #CodingInterview #Python #Arrays #PrefixSuffix #ProblemSolving
To view or add a comment, sign in
-
-
🚀 DSA Challenge – Day 96 Problem: String to Integer (atoi) 🔢➡️💻 This is a classic implementation problem that tests careful handling of edge cases, parsing logic, and boundary conditions. 🧠 Problem Summary: Implement the function myAtoi(string s) that converts a string into a 32-bit signed integer following specific parsing rules. Steps to follow: 1️⃣ Ignore leading whitespaces. 2️⃣ Check the sign (+ or -). 3️⃣ Read digits until a non-digit character is found. 4️⃣ Handle overflow/underflow by clamping the number within the 32-bit signed integer range: Range = [−2³¹, 2³¹ − 1] 5️⃣ Return the final integer. ⚙️ My Approach: Trim leading spaces using lstrip(). Identify the sign based on the first non-space character. Iterate through the string and build the number digit by digit. Multiply by the sign and ensure the result stays within integer limits using max() and min(). 📈 Complexity Analysis: Time: O(n) — traverse each character once. Space: O(1) — only a few variables used. ✨ Key Takeaway: This problem is a great example of careful boundary handling and parsing logic — it’s not just about coding, but about thinking through every possible input case. 🔖 #DSA #100DaysOfCode #LeetCode #ProblemSolving #Python #CodingChallenge #myAtoi #StringParsing #AlgorithmDesign #InterviewPrep #TechCommunity #LearningEveryday
To view or add a comment, sign in
-
-
🧩 Day 54 of my LeetCode Challenge Problem: 3217. Delete Nodes From Linked List Present in Array Difficulty: Medium 🧠 💡 Intuition: We’re given a linked list and an array of integers. Our task is to delete all nodes from the linked list whose values are present in the given array. The trick here is to ensure we do it efficiently since both the array and list can be large. 🧠 Approach: Convert the array nums into a set for O(1) lookups. Use a dummy node to simplify edge cases like deleting the head. Traverse the list using two pointers (prev and cur). If a node’s value exists in the set, skip it. Otherwise, move forward. Finally, return the modified list starting from dummy.next. ⏱ Complexity: Time: O(n + m) Space: O(m) ✅ Example: Input: nums = [1,2,3], head = [1,2,3,4,5] Output: [4,5] Nodes with values 1, 2, and 3 are deleted, leaving the clean list [4,5]. 💬 Takeaway: Efficient lookups with a set and clean traversal logic make linked list problems much easier! #LeetCode #Day54 #LinkedList #Python #CodingChallenge
To view or add a comment, sign in
-
-
🚀Day 56 of #100DaysOfCode 🚀Solved LeetCode Problem 3347 – Maximum Frequency of an Element After Performing Operations II (Hard) This problem tested efficient use of sorting + sliding window technique to maximize element frequency after limited operations. The challenge was to determine how far we can extend a subarray where values can be adjusted within a range [-k, k] using at most num Operations modifications — achieving an optimized O(n log n) approach. Runtime: 266 ms — Beats 98.39% Memory: 31.96 MB — Beats 95.16% Key Concepts: Sorting for value proximity alignment Two-pointer technique for maintaining valid operation windows Cumulative operation cost calculation to ensure feasibility Feeling great to see consistent performance improvements and algorithmic clarity growing day by day! 🚀 #LeetCode #100DaysOfCode #Python #ProblemSolving #DataStructures #Algorithms
To view or add a comment, sign in
-
-
🚀 DSA Progress – Day 101 ✅ Problem #443: String Compression 🧠 Difficulty: Medium | Topics: Array, String, Two Pointers, In-place Modification 🔍 Approach: Implemented an in-place array compression using two pointers: Step 1 (Traversal): Use a pointer i to traverse the array and a pointer index to write compressed characters. Step 2 (Count Repeats): For each character, count consecutive repeating characters. Step 3 (Write Characters): Write the character at chars[index]. If count > 1, convert it to a string and write each digit at chars[index]. Increment index accordingly. Step 4 (Continue): Repeat until the entire array is processed. Return index as the new length. 🕒 Time: O(n), traverse array once. 💾 Space: O(1), in-place modification, no extra array. 📁 File: https://lnkd.in/gH_3QQgU 📚 Repo: https://lnkd.in/g8Cn-EwH 💡 Learned: This problem reinforced the two-pointer technique and in-place array manipulation. It helped me practice handling consecutive elements efficiently and writing counts correctly without extra space. Breaking it into traversal + counting + writing made the solution clean and modular. ✅ Day 101 complete — compressed sequences in arrays like a pro! ✨🔡📏 #LeetCode #DSA #Python #Array #String #TwoPointers #InPlace #DailyCoding #InterviewPrep #GitHubJourney
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