🚀 Day 78 of #100DaysOfDSA 🚀 Solved LeetCode 205 — Isomorphic Strings 🔹 Problem: Check if two strings s and t are isomorphic. Two strings are isomorphic if each character in s can be replaced to get t, with no two characters mapping to the same character (but a character can map to itself). 🔹 Approach: Bidirectional Hash Mapping (One-to-One Mapping Check) If lengths differ → return False immediately. Maintain two dictionaries: mapping1 for s → t mapping2 for t → s Traverse both strings simultaneously: Ensure the mapping is consistent in both directions. If any conflict appears, return False. ✨ Key Insight: Use two-way mapping to ensure one-to-one correspondence — avoiding false positives in character transformations. #LeetCode #Python #HashMap #Strings #DSA #ProblemSolving #100DaysOfCode #CodingJourney 🚀
Solved LeetCode 205: Isomorphic Strings with Bidirectional Hash Mapping
More Relevant Posts
-
Day 66: Find Minimum in Rotated Sorted Array II 📉 (Simple Version) I'm tackling an advanced Binary Search problem on Day 66 of #100DaysOfCode: "Find Minimum in Rotated Sorted Array II." The challenge is to find the minimum element in a rotated sorted array that may contain duplicates. My solution uses a modified Binary Search approach. The key difficulty is when the middle element (nums[mid]) equals the rightmost element (nums[right]). In this case, we can't tell if the minimum is on the left or the right. To resolve this ambiguity, I simply discard the rightmost element by setting right -= 1. This adjustment keeps the search on track, achieving an optimal O(log n) complexity in the typical case. My solution achieved 100% runtime efficiency! #Python #DSA #Algorithms #BinarySearch #Arrays #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀Day 80 of #100DaysOfDSA 🚀 Solved LeetCode 451 — Sort Characters By Frequency 🔹 Problem: Sort a string based on the frequency of its characters in descending order. 🔹 Approach: Used Hash Map + Sorting 1️⃣ Count frequency of each character using a dictionary 2️⃣ Sort characters by their frequency (descending) 3️⃣ Rebuild the string by repeating characters based on count ✨ Key Insight: Hash maps are great for frequency counting, and sorting by values helps in many pattern-based problems. #LeetCode #DSA #Python #ProblemSolving #HashMap #Sorting #CodingJourney #100DaysOfCode 🚀
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟯𝟵 𝗼𝗳 #𝟭𝟴𝟬𝗗𝗮𝘆𝘀𝗢𝗳𝗖𝗼𝗱𝗲 Today, I built on the first/last occurrence solution to 𝗰𝗼𝘂𝗻𝘁 𝗼𝗰𝗰𝘂𝗿𝗿𝗲𝗻𝗰𝗲𝘀 𝗼𝗳 𝗮 𝘁𝗮𝗿𝗴𝗲𝘁 𝗶𝗻 𝗮 𝘀𝗼𝗿𝘁𝗲𝗱 𝗮𝗿𝗿𝗮𝘆 𝘄𝗶𝘁𝗵 𝗱𝘂𝗽𝗹𝗶𝗰𝗮𝘁𝗲𝘀. Using the same lower_bound and upper_bound helpers: Lower bound → first index where element ≥ target Upper bound → first index where element > target The count is simply: count = upper_bound - lower_bound This gives an O(log n) solution — much faster than scanning the entire array, especially with many duplicates. It’s a great example of how breaking a problem into reusable pieces leads to clean and efficient code. Perfect for analytics, frequency analysis, and search optimizations! 📊 #Python #Algorithms #BinarySearch #FrequencyCount #Coding #ProblemSolving
To view or add a comment, sign in
-
-
LeetCode 90-Day Challenge – Day 78 Problem: Find Peak Element Difficulty: Medium Problem: We need to find a peak element in an array, an element that is strictly greater than its neighbors. If multiple peaks exist, returning the index of any one of them is valid. Conceptually, nums[-1] and nums[n] are considered negative infinity, so edge elements can also be peaks. The challenge is to achieve this in O(log n) time. Solution approach: This problem can be efficiently solved using binary search. At each step, we check the middle element and compare it with its right neighbor. If the middle element is smaller than the next one, it means the peak lies on the right half; otherwise, the peak is on the left half. By continuously narrowing down the range, we find a peak element in logarithmic time. #LeetCode #90DaysOfCode #Python #LinkedInChallenge #CodingJourney #ProblemSolving #LeetCodeChallenge
To view or add a comment, sign in
-
-
#96day of #100DaysOfCode 🌱 LeetCode 109: Convert Sorted List to Binary Search Tree Today’s challenge was about building balance — literally! Given a sorted linked list, we need to convert it into a height-balanced BST 🌳 🧠 Key Idea: The middle element of the list becomes the root. Left half forms the left subtree, right half forms the right subtree. Use slow–fast pointers to find the middle efficiently. 📈 Complexity: Time: O(n log n) Space: O(log n) (recursion stack) 💬 Learning: Balance matters — in trees, in code, and in life 🌿 Sometimes, the middle point creates the strongest foundation. #LeetCode #DSA #BinarySearchTree #LinkedList #CodingChallenge #Python #Algorithm #LeetCodeDaily #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 LeetCode #1625: Lexicographically Smallest String After Applying Operations Today’s problem was about transforming a numeric string using two operations: adding a value to digits at odd indices and rotating the string, to get the lexicographically smallest result possible. The challenge was to handle infinite possibilities smartly. I used a Breadth First Search (BFS) approach to systematically explore all reachable string states while keeping track of visited ones. 💡 Key Takeaways: - Some problems don’t need a direct formula, they need systematic exploration. - BFS is not just for graphs; it’s a powerful tool for exploring state transitions too. - Modular arithmetic and rotation logic often come together in string manipulation problems. This one was a great reminder that clean logic and state tracking can solve even the most “infinite looking” problems efficiently. #LeetCode #ProblemSolving #Python #DSA #CodingChallenge #Algorithms #BFS #StringManipulation #LearningEveryday
To view or add a comment, sign in
-
-
💻 Day 1 of Week 2 #Learning_Of_DSA 🚀 Today’s #LeetCode_Problem_2149 – Rearrange Array Elements by Sign. At first glance, it looked straightforward… but the real test was in maintaining order and structure, just like writing clean backend routes 🧠 Approach: ✅ Separate the +ve and -ve value and arrange in resultant array. Complexity: 🕒 Time – O(n) 💾 Space – O(n) Takeaway: Sometimes, the solution isn’t about “big algorithms” — it’s about organized logic. #LeetCode #ProblemSolving #Python #LearnInPublic #SoftwareEngineering #CodingJourney #CareerGrowth #100DaysOfCode #Motivation #MERNStack #DSA
To view or add a comment, sign in
-
-
365 Days of DSA – #Day193: Insert Interval ➕📅 Today’s challenge — Insert a new interval into a list of non-overlapping intervals and merge when needed! This problem tests interval handling, merging logic & careful pointer movement. 🧠 Approach summary: 🔹 Add all intervals ending before the new one 🔹 Merge overlapping intervals with the new range 🔹 Append the rest untouched Result: clean & efficient interval insertion! ⚡ #Day193 #365DaysOfDSA #Intervals #GreedyAlgorithm #LeetCode #Python #ProblemSolving #DSA #CodingChallenge #LogicBuilding
To view or add a comment, sign in
-
-
🚀 Day 43 of #100DaysOfDSA 💡 Problem: 993. Cousins in Binary Tree 🔗 LeetCode: https://lnkd.in/djrWKuC4 🧠 Approach: - Used DFS to record the depth and parent of both target nodes (x and y). - Compared their depths and parents to check if they are cousins (same level, different parents). - Used recursion for clean and efficient traversal. 📚 Learnings: - Strengthened understanding of tree traversal using recursion. - Learned to track multiple attributes (depth, parent) simultaneously. - Improved logical reasoning for binary tree relationship problems. 👨💻 LeetCode Profile: https://lnkd.in/dGQwSXjb #100DaysOfDSA #Day43 #LeetCode #Python #BinaryTree #DFS #Recursion #ProblemSolving #CodingChallenge
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