⚡ 𝗗𝗮𝘆 𝟳𝟱 𝗼𝗳 𝗠𝘆 𝟭𝟬𝟬 𝗗𝗮𝘆𝘀 𝗼𝗳 𝗗𝗦𝗔 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲! 𝘛𝘰𝘥𝘢𝘺’𝘴 𝘱𝘳𝘰𝘣𝘭𝘦𝘮 𝘸𝘢𝘴 𝘢 𝘨𝘳𝘦𝘢𝘵 𝘮𝘪𝘹 𝘰𝘧 𝙨𝙩𝙧𝙞𝙣𝙜 𝙥𝙧𝙤𝙘𝙚𝙨𝙨𝙞𝙣𝙜 𝙖𝙣𝙙 𝙢𝙖𝙩𝙝𝙚𝙢𝙖𝙩𝙞𝙘𝙖𝙡 𝙩𝙝𝙞𝙣𝙠𝙞𝙣𝙜, 𝘪𝘯𝘴𝘱𝘪𝘳𝘦𝘥 𝘣𝘺 𝘢 𝘳𝘦𝘢𝘭-𝘸𝘰𝘳𝘭𝘥 𝘴𝘺𝘴𝘵𝘦𝘮 𝘸𝘦 𝘢𝘭𝘭 𝘳𝘦𝘤𝘰𝘨𝘯𝘪𝘻𝘦 𝘌𝘹𝘤𝘦𝘭 𝘤𝘰𝘭𝘶𝘮𝘯𝘴. 📌 Problem Solved: 1️⃣ 𝗟𝗲𝗲𝘁𝗰𝗼𝗱𝗲 171: Excel Sheet Column Number ✨ Key Learnings: 🔹 This problem is essentially about 𝗯𝗮𝘀𝗲-𝟮𝟲 𝗻𝘂𝗺𝗯𝗲𝗿 𝗰𝗼𝗻𝘃𝗲𝗿𝘀𝗶𝗼𝗻, where characters act as digits instead of numbers. 🔹 Iterating through the string and updating the result as result = result * 26 + currentCharValue helps build the column number efficiently. 🔹 It reinforced how 𝗰𝗵𝗮𝗿𝗮𝗰𝘁𝗲𝗿-𝘁𝗼-𝗻𝘂𝗺𝗯𝗲𝗿 𝗺𝗮𝗽𝗽𝗶𝗻𝗴 ('A' → 1 to 'Z' → 26) plays a crucial role in many string-based problems. 🧠 Big Takeaway: Problems that look string-heavy often boil down to 𝘀𝗶𝗺𝗽𝗹𝗲 𝗺𝗮𝘁𝗵 + 𝗶𝘁𝗲𝗿𝗮𝘁𝗶𝗼𝗻 once the pattern is clear. Day 75 completed — slowly but surely stacking fundamentals! 💪🔥 #100DaysOfCode #DSA #Java #Strings #ProblemSolving #LogicBuilding #InterviewPreparation #LeetCode #LearningInPublic #Developers
Day 75 of 100 Days of DSA: Excel Sheet Column Number
More Relevant Posts
-
Day 3 – DSA Journey | Arrays 🚀 Today’s focus was on 3-sum variations, where sorting + two pointers do most of the heavy lifting. ✅ Problems Solved 📌 3Sum 📌 3Sum Closest 🔹 3Sum Approach: Sorted the array Fixed one element and used two pointers to find valid triplets Skipped duplicates to avoid repeated results Key Learning: ✅ Sorting simplifies multi-pointer logic ✅ Duplicate handling is critical for correctness Complexity: ⏱ Time: O(n²) 📦 Space: O(1) (excluding output) 🔹 3Sum Closest Approach: Sorted the array Fixed one element and adjusted pointers based on how close the sum was to the target Updated the closest sum whenever a better match was found Key Learning: ✅ Greedy updates help converge quickly ✅ Absolute difference comparison is a powerful pattern Complexity: ⏱ Time: O(n²) 📦 Space: O(1) 🧠 Takeaway Once you understand sorting + two pointers, many array problems start looking familiar. Consistency > Complexity. On to Day 4 🔁🚀 #DSA #Arrays #TwoPointers #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
-
Contains Duplicate — LeetCode 217 Hi all 👋 Today this is my first post related to a DSA problem. Goal Check whether an array contains duplicate numbers or not. n = Length of array idx = Index of array element Brute Force Approach Select each element and compare it with all other elements in the array. If any same value is found, return "true"; otherwise return "false". Time Complexity: O(n²) Space Complexity: O(1) Reason: every element is compared with others. Better Approach (Sorting) If we sort the array, duplicate elements come next to each other. After sorting, we simply compare adjacent elements. 🕸 Trap Empty array or single element array (idx < n-1) Time Complexity: O(n log n) Space Complexity: Depends on the sorting algorithm. Optimized Approach (Using Set) Before moving forward, let’s recall one important data structure — Set. A set: - Performs operations in average O(1) time - Does not allow duplicates Approach: - Traverse the array from the first element. - Check if the element already exists in the set. - If yes → duplicate found → return "true". - Otherwise, add the element to the set. The key idea: if we encounter the same element again, it means a duplicate exists. Time Complexity: O(n) Space Complexity: O(n) (in worst case when no duplicates exist) 🔁 Trade-off In real-world problems, we often optimize for time complexity. - If extra space is allowed → use Set (best time). - If space is restricted → prefer Sorting. Whenever you see duplicate or frequency type problems, think about: ➡️ Sorting ➡️ HashSet / HashMap If I missed anything or if you have a better approach, please feel free to add it in the comments. Thanks for reading 🙌 #DSA #LeetCode #Java #CodingJourney #DataStructures #Algorithms #ProblemSolving #SoftwareEngineer #TechLearning #InterviewPreparation
To view or add a comment, sign in
-
Day 18 – Solving 3Sum (LeetCode) Today I solved the 3Sum problem on LeetCode using an optimized approach 💻 🔹 Problem: Given an integer array, find all unique triplets whose sum is 0. 🔹 Example: Input: [-1, 0, 1, 2, -1, -4] Output: [[-1, -1, 2], [-1, 0, 1]] 🧠 What I learned How sorting helps reduce unnecessary comparisons How to use the two-pointer technique How to avoid duplicate triplets ⚙️ Approach Sort the array Fix one element Use two pointers to find the remaining two elements Skip duplicates This reduces time complexity from O(n³) to O(n²) 💡 Improving my Data Structures & Algorithms skills one day at a time #Day18 #LeetCode #3Sum #DSA #Java #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟒 – 𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 | 𝐀𝐫𝐫𝐚𝐲𝐬 🚀 Today’s problems pushed me to think more about optimization, pruning, and duplicate handling. ✅ 𝐏𝐫𝐨𝐛𝐥𝐞𝐦𝐬 𝐒𝐨𝐥𝐯𝐞𝐝 📌 4Sum 📌 Remove Duplicates from Sorted Array 🔹 𝟒𝐒𝐮𝐦 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Sorted the array Fixed two indices and used 𝐭𝐰𝐨 𝐩𝐨𝐢𝐧𝐭𝐞𝐫𝐬 for the remaining pair Applied 𝐞𝐚𝐫𝐥𝐲 𝐩𝐫𝐮𝐧𝐢𝐧𝐠 using the minimum and maximum possible sums Carefully skipped duplicates at every level 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠: ✅ Pruning reduces unnecessary iterations ✅ Using long avoids integer overflow ✅ Duplicate handling is the hardest (and most important) part 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: ⏱ Time: O(n³) 📦 Space: O(1) (excluding output) 🔹 𝐑𝐞𝐦𝐨𝐯𝐞 𝐃𝐮𝐩𝐥𝐢𝐜𝐚𝐭𝐞𝐬 𝐟𝐫𝐨𝐦 𝐒𝐨𝐫𝐭𝐞𝐝 𝐀𝐫𝐫𝐚𝐲 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Used 𝐭𝐰𝐨 𝐩𝐨𝐢𝐧𝐭𝐞𝐫𝐬 One pointer tracks the last unique element Overwrote duplicates in-place 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠: ✅ Sorted arrays enable in-place solutions ✅ Simple logic can be extremely efficient 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: ⏱ Time: O(n) 📦 Space: O(1) 🧠 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 Optimization is not about writing complex code — it’s about 𝐚𝐯𝐨𝐢𝐝𝐢𝐧𝐠 𝐮𝐧𝐧𝐞𝐜𝐞𝐬𝐬𝐚𝐫𝐲 𝐰𝐨𝐫𝐤. On to 𝐃𝐚𝐲 𝟓 🔁🚀 #DSA #Arrays #TwoPointers #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟱𝟵/𝟭𝟬𝟬 — 𝗢𝗻𝗲 𝗗𝗮𝘆 𝗧𝗼 𝟲𝟬 Day 59. One day away from another milestone. But today? Simple string manipulation. Two pointers. Classic reversal. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ #𝟮𝟬𝟬𝟬: Reverse Prefix of Word (Easy) 𝗧𝗵𝗲 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: Given a word and a character, reverse the prefix up to the first occurrence of that character. Example: word = "abcdefd", ch = 'd' Result = "dcbaefd" (Reverse "abcd" → "dcba", keep "efd") 𝗧𝗵𝗲 𝗦𝗼𝗹𝘂𝘁𝗶𝗼𝗻: Find the index. Two-pointer swap. Done. 👉 Find first occurrence of character 👉 If not found, return original word 👉 Two pointers: left = 0, right = index 👉 Swap characters while moving inward 👉 Return modified string Time: O(n), Space: O(n) for char array 𝗪𝗵𝘆 𝗜𝘁 𝗠𝗮𝘁𝘁𝗲𝗿𝘀: Two-pointer reversal. Day 31 used it for linked lists. Day 59 uses it for strings. Same pattern. Different data structure. That's the power of understanding fundamentals—they transfer. 𝗖𝗼𝗱𝗲: https://lnkd.in/g7UXBf_u 59 down. 41 to go. Tomorrow = 60. 𝗗𝗮𝘆 𝟱𝟵/𝟭𝟬𝟬 ✅ #100DaysOfCode #LeetCode #Strings #TwoPointer #Algorithms #ProblemSolving #CodingInterview #Programming #Java #Fundamentals #Day60Tomorrow
To view or add a comment, sign in
-
𝗗𝗮𝘆 𝟱𝟲/𝟭𝟬𝟬 — 𝗕𝗮𝗰𝗸 𝘁𝗼 𝘁𝗵𝗲 𝗖𝗹𝗮𝘀𝘀𝗶𝗰𝘀 Day 56. Valid Parentheses. The problem everyone sees on Day 1 of learning stacks. Except this time? I actually get why it works. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ #𝟮𝟬: Valid Parentheses (Easy) 𝗧𝗵𝗲 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: Given a string of brackets: (), {}, []. Check if they're properly matched and nested. Examples: "()" → Valid "([)]" → Invalid (wrong order) "{[]}" → Valid (properly nested) 𝗧𝗵𝗲 𝗦𝗼𝗹𝘂𝘁𝗶𝗼𝗻: Stack. That's it. Push opening brackets. When you see a closing bracket, check if it matches the stack top. If yes, pop. If no, invalid. Empty stack at the end = valid. First time I saw this problem, I thought "why use a stack?" Now I see it—LIFO matches the nesting structure perfectly. 𝗪𝗵𝘆 𝗜𝘁 𝗠𝗮𝘁𝘁𝗲𝗿𝘀: This isn't just about parentheses. It's about recognizing when a problem needs LIFO behavior. Compilers use this. Code editors use this. Expression parsing uses this. Pattern recognition >> memorization. 𝗖𝗼𝗱𝗲: https://lnkd.in/gdCu84Ja 56 down. 44 to go. 𝗗𝗮𝘆 𝟱𝟲/𝟭𝟬𝟬 ✅ #100DaysOfCode #LeetCode #Stack #DataStructures #Algorithms #ProblemSolving #CodingInterview #Programming #Java #PatternRecognition
To view or add a comment, sign in
-
Most people solve this in O(n²). I almost did too. But today I learned a simple trick that makes it O(n). 🚀 Day 55/365 — DSA Challenge Solved: Find Pivot Index The problem is simple: Find an index where left sum == right sum Example: [1,7,3,6,5,6] → answer = 3 My first thought: For every index → calculate left sum & right sum Works… But too slow ❌ Then I realized something: You don’t need to recalculate everything. You already have the total sum. 💡 Key idea: Right sum = totalSum - leftSum - current So instead of nested loops… You just keep updating leftSum. One pass. Clean logic. Optimal solution. ⏱ O(n) time 📦 O(1) space This problem taught me: Simple problems still test your thinking. Optimization matters. And most importantly… Don’t overcomplicate. Code 👇 https://lnkd.in/dad5sZfu #DSA #LearningInPublic #Java #Coding #LeetCode #Consistency #365Days365DSAProblems
To view or add a comment, sign in
-
-
Day 58/100 – LeetCode Challenge ✅ Problem: Longest Balanced Substring II Difficulty: Medium Language: Java Approach: Multiple Pattern Detection + Prefix Difference Mapping Time Complexity: O(n) Space Complexity: O(n) Key Insight: Balanced substrings must have equal counts of characters in three possible patterns: Single character run - consecutive same characters Two characters - equal occurrences of two specific chars Three characters - all three chars appear same number of times Solution Brief: countOne(): Track longest consecutive run of same character. countTwo(): For two chars (like 'a'/'b'), use prefix sum where n1=+1, n2=-1; reset on other chars. countThree(): Track differences (a-b) and (a-c) as state; when same state repeats, balanced substring found. #LeetCode #Day58 #100DaysOfCode #String #HashMap #Java #Algorithm #CodingChallenge #ProblemSolving #LongestBalancedSubstringII #HardProblem #PrefixSum #StateTracking #DSA
To view or add a comment, sign in
-
-
📌 17. Letter Combinations of a Phone Number (Medium) Today’s problem was all about Backtracking & Recursion. 🧠 Problem Summary Given digits from 2–9, return all possible letter combinations based on phone keypad mapping. Example: Input: "23" Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"] 💡 Key Insight This is a classic Cartesian Product problem. Each digit expands into multiple choices → Perfect use case for Backtracking. 🚀 Approach Create a digit → letter mapping Use recursion to build combinations When current string length == digits length → Add to result Backtrack and explore next possibilities ⏱ Complexity Time: O(4ⁿ) Space: O(n) recursion stack Max combinations = 256 (since n ≤ 4) 🎯 What I Practiced Today ✅ Recursion Tree Thinking ✅ Backtracking Pattern ✅ StringBuilder Optimization ✅ Clean Code Structure Consistency > Motivation 💪 Day 18 completed. #LeetCode #Java #DataStructures #Algorithms #Backtracking #100DaysOfCode
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟐𝟓 – 𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 | 𝐀𝐫𝐫𝐚𝐲𝐬 🚀 Today’s problem focused on sorting an array containing only three distinct values using an efficient counting approach. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐞𝐝 • Sort Colors 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 𝟏 – 𝐂𝐨𝐮𝐧𝐭𝐢𝐧𝐠 𝐀𝐫𝐫𝐚𝐲 • Created a count array of size 3 • Counted occurrences of 0, 1, and 2 • Overwrote the original array using the frequency values • Simple and easy to implement 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬 • When value range is small, counting is powerful • Rewriting the array can be simpler than swapping • Constraints often guide the optimal approach • Clear thinking avoids overcomplication 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 • Time: O(n) • Space: O(1) (since count array size is constant) 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 Not every sorting problem needs full sorting logic — sometimes counting is enough. 25 days consistent. On to Day 26 🚀 #DSA #Arrays #Sorting #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
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