🔹 Day 37: Isomorphic Strings (LeetCode #205) 📌 Problem Statement: Given two strings s and t, determine if they are isomorphic — meaning each character in s can be replaced to get t, while maintaining order and uniqueness of mapping. ✅ My Approach: I used two HashMaps to track character mappings in both directions — one from s → t and another from t → s. While iterating through each character pair, I ensured that: A character maps consistently to the same one. No two characters map to the same character. 📊 Complexity: Time Complexity: O(n) Space Complexity: O(n) ⚡ Submission Stats: Runtime: 24 ms (Beats 12.67%) Memory: 42.46 MB (Beats 72.43%) 💡 Reflection: This problem deepened my understanding of bidirectional mapping and consistency checks in string transformations. Elegant use of HashMaps for ensuring one-to-one character relationships! 🔁 #LeetCode #Java #HashMap #Strings #100DaysOfCode #Day37
Isomorphic Strings Solution with HashMaps
More Relevant Posts
-
💻 Day 19 of My LeetCode Journey 🧩 Problem: 205. Isomorphic String ✨ My Approach: To check if two strings are isomorphic, I used two HashMaps — one to store character mappings from string s to string t, and another to track whether a character in t has already been mapped. 🔹 If a mapping already exists, I verify that it’s consistent. 🔹 If not, I ensure no two characters from s map to the same character in t. 🔹 If all mappings hold correctly, the strings are isomorphic. ⚙️ Time Complexity: O(n) 💾 Space Complexity: O(n) ✅ Learning: This problem helped me understand the concept of one-to-one mapping between characters and how to use HashMap effectively to track relationships between elements. #Day19 #LeetCode #Java #CodingJourney #ProblemSolving #IsomorphicStrings #HashMap #LearningEveryday #DataStructures
To view or add a comment, sign in
-
-
🚀 Day 42 of #100DaysOfLeetCode Today's challenge: Binary Tree Preorder Traversal (LeetCode #144) 🌳 📘 Concept: Preorder traversal follows the order — Root → Left → Right. It’s one of the fundamental ways to explore a binary tree, and it helps build a strong base for understanding recursion and tree-based algorithms. 🧠 Approach Used: Used a simple recursive solution to visit the root first, then the left subtree, and finally the right subtree. 💡 Key Takeaway: Recursion becomes easy once you visualize how the function calls go deep into left and right subtrees. Trees are all about patterns! #LeetCode #100DaysChallenge #Day42 #CodingJourney #BinaryTree #Recursion #Java
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 71 String Rotation Task: Given two strings s and goal, determine if s can become goal after some number of rotations (moving the first character to the end each time). Example: Input: s = "abcde", goal = "cdeab" Output: true My Approach First, check if both strings have the same length otherwise, rotation is impossible. Then, observe that any valid rotation of s will always appear as a substring in s + s. Simply check: return (s + s).contains(goal); Time Complexity: O(N²) Space Complexity: O(N) Sometimes, elegant insights lead to minimal code doubling a string can reveal every possible rotation effortlessly! #LeetCode #100DaysOfCode #Java #CodingChallenge #ProblemSolving #StringManipulation #takeUforward #GeeksForGeeks #CodeNewbie #InterviewPrep
To view or add a comment, sign in
-
-
🚀 Day 42 of #100DaysOfLeetCode Today's challenge: Binary Tree Preorder Traversal (LeetCode #144) 🌳 📘 Concept: Preorder traversal follows the order — Root → Left → Right. It’s one of the fundamental ways to explore a binary tree, and it helps build a strong base for understanding recursion and tree-based algorithms. 🧠 Approach Used: Used a simple recursive solution to visit the root first, then the left subtree, and finally the right subtree. 💡 Key Takeaway: Recursion becomes easy once you visualize how the function calls go deep into left and right subtrees. Trees are all about patterns! #LeetCode #100DaysChallenge #Day42 #CodingJourney #BinaryTree #Recursion #Java
To view or add a comment, sign in
-
-
🚀 Day 42 of #100DaysOfLeetCode Today's challenge: Binary Tree Preorder Traversal (LeetCode #144) 🌳 📘 Concept: Preorder traversal follows the order — Root → Left → Right. It’s one of the fundamental ways to explore a binary tree, and it helps build a strong base for understanding recursion and tree-based algorithms. 🧠 Approach Used: Used a simple recursive solution to visit the root first, then the left subtree, and finally the right subtree. 💡 Key Takeaway: Recursion becomes easy once you visualize how the function calls go deep into left and right subtrees. Trees are all about patterns! #LeetCode #100DaysChallenge #Day42 #CodingJourney #BinaryTree #Recursion #Java
To view or add a comment, sign in
-
-
🔹 Day 46: Is Subsequence (LeetCode #392) 📌 Problem Statement: Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence is formed by deleting some (possibly none) characters from the original string without disturbing the relative order of the remaining characters. ✅ My Approach: I used a two-pointer technique — one pointer iterates through string t, and the other tracks progress through string s. Each time a matching character is found, the pointer for s moves forward. If we reach the end of s, it means all its characters appeared in sequence within t. 📊 Complexity: Time Complexity: O(n) Space Complexity: O(1) ⚡ Submission Stats: Runtime: 2 ms (Beats 68.53%) Memory: 41.32 MB (Beats 87.28%) 💡 Reflection: A simple yet elegant problem that highlights how pointer movement can efficiently handle string comparisons without extra memory usage. ✨ #LeetCode #Java #Strings #TwoPointers #100DaysOfCode #Day46
To view or add a comment, sign in
-
-
Day 31/100 – #100DaysOfCode 🚀 | #Java #LeetCode #Sorting #Arrays ✅ Problem Solved: Maximum Gap ⚙️ 🧩 Problem Summary: Given an unsorted array, find the maximum difference between successive elements in its sorted form. You must solve it in linear time and space. 💡 Approach Used: Used Bucket Sort (Pigeonhole Principle) to achieve linear performance — ➤ Calculated global min & max. ➤ Divided range into buckets based on array size. ➤ Placed elements into buckets tracking min & max of each. ➤ Found maximum gap between successive non-empty buckets. ⚙️ Time Complexity: O(N) 📦 Space Complexity: O(N) ✨ Takeaway: This problem sharpened my understanding of bucket-based approaches and how sorting principles can be applied efficiently without direct sorting. ⚡ #Java #LeetCode #BucketSort #Sorting #ProblemSolving #100DaysOfCode #CodingChallenge
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 67 Reverse Words in a String Problem: – Reverse Words in a String Task: – Given a string, reverse the order of the words and remove extra spaces. Example: Input: s = " the sky is blue " → Output: "blue is sky the" My Approach: Used trim() to remove leading and trailing spaces. Split the string using split("\\s+") to handle multiple spaces. Reversed the array and joined the words with a single space. Time Complexity: O(N) | Space Complexity: O(N) Even simple string problems can teach the importance of clean code and efficient use of built-in methods. #takeUforward #100DaysOfCode #Java #ProblemSolving #LeetCode #GeeksForGeeks #CodeNewbie #StringManipulation
To view or add a comment, sign in
-
-
💡 LeetCode #344 — Reverse String Today I solved LeetCode Problem 344: Reverse String 🔁 Problem Summary: Write a function that reverses a string. The input string is given as a character array s, and you must reverse it in-place (without using extra space). Key Idea: Use the two-pointer technique 👈👉 Initialize one pointer at the start (left) and another at the end (right). Swap the characters at both pointers and move them toward the center. #LeetCode #Java #DSA #TwoPointers #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 74 Count and Say Problem: Given an integer n, return the n-th term of the “Count and Say” sequence a fascinating pattern where each term describes the previous one. Example: Input: n = 4 Output: "1211" My Approach: Used recursion to generate the previous term. Applied run-length encoding logic counted consecutive digits and built the next term using a StringBuilder. Optimized for clean, readable iteration with O(N²) complexity (due to string building). Understanding recursive string construction deepens how we visualize “generation-based” sequences it’s not just about coding, it’s about seeing patterns grow. #100DaysOfCode #Java #LeetCode #ProblemSolving #Recursion #StringManipulation #CodingJourney #TechWithPurpose #takeUforward
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