Day 5/50 | #50DaysOfCode 📍 Platform: LeetCode 💻 Language: Java ✅ 1662. Check If Two String Arrays are Equivalent (Easy) Today’s problem focused on string concatenation and comparison. It helped reinforce my understanding of arrays, string handling, and equality checks. 🔎 Approach: Concatenate all elements of word1 to form a single string Concatenate all elements of word2 to form another string Compare the two resulting strings If both strings are equal, return true, otherwise false 📌 Example: Input: word1 = ["ab","c"], word2 = ["a","bc"] Output: true Explanation: word1 → "ab" + "c" = "abc" word2 → "a" + "bc" = "abc" Both strings are equal. This problem strengthened my understanding of string manipulation and array traversal in Java. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #Consistency #LearningJourney #50DaysOfCode #LinkedIn
Java LeetCode Challenge: String Array Comparison
More Relevant Posts
-
Day 7/50 | #50DaysOfCode 📍 Platform: LeetCode 💻 Language: Java ✅ 167. Two Sum II - Input Array Is Sorted (Medium) Today’s problem focused on finding two numbers in a sorted array that sum up to a target. It helped reinforce the two-pointer technique and efficient array traversal. 🔎 Approach: Use two pointers: one at the start (left) and one at the end (right) of the array Calculate the sum of numbers at both pointers If sum equals target, return the 1-indexed positions [left+1, right+1] If sum < target, move left pointer forward If sum > target, move right pointer backward Continue until the solution is found 📌 Example: Input: numbers = [2,7,11,15], target = 9 Output: [1,2] Explanation: 2 + 7 = 9 → indices 1 and 2 This problem strengthened my understanding of two-pointer techniques, sorted arrays, and constant space solutions in Java. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #Consistency #LearningJourney #50DaysOfCode #LinkedIn
To view or add a comment, sign in
-
-
Day 5/50 | #50DaysOfCode 📍 Platform: LeetCode 💻 Language: Java ✅ 205. Isomorphic Strings (Easy) Today’s problem focused on understanding character mapping between two strings. It helped strengthen my knowledge of HashMap usage and maintaining one-to-one relationships between characters. 🔎 Approach: Traverse both strings simultaneously Use a HashMap to map characters from string s to string t Ensure each character maps to only one unique character Also verify that two different characters do not map to the same character If all mappings are valid, return true, otherwise false 📌 Example: Input: s = "egg", t = "add" Output: true Explanation: 'e' → 'a' 'g' → 'd' This problem improved my understanding of character mapping, HashMap logic, and string traversal in Java. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #Consistency #LearningJourney #50DaysOfCode #LinkedIn
To view or add a comment, sign in
-
-
🚀 Day 42/100 Today I worked on an interesting problem: String Rotation Check 🔄. 💡 Problem: Given two strings "s" and "goal", check whether "s" can be converted to "goal" by performing multiple left shifts. 🧠 What I Learned: - How string rotation works using shifting - A smart trick: 👉 If "goal" is a rotation of "s", then it will always be a substring of "s + s" - Improved understanding of string manipulation in Java. 💻 Approach: - First check if lengths are equal - Then check if "(s + s).contains(goal)" 🔍 Example: "s = "abcde"" "goal = "cdeab"" → ✅ True Sometimes problems look complex, but a simple trick can solve them efficiently! #Day42 #100DaysOfCode #Java #DSA #Learning #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
LeetCode Problem || Find Unique Binary String (1980)🚀 Today I solved the problem "Find Unique Binary String" using Java. 🔹 Problem: We are given an array of n binary strings, each of length n. The goal is to return a binary string of length n that does not exist in the array. 🔹 Approach (Diagonal Flip Technique): The idea is simple but powerful: Traverse the array using index i. Look at the i-th character of the i-th string (nums[i][i]). Flip the bit (0 → 1, 1 → 0). Append it to a result string. 💡 Time Complexity: O(n) Practicing problems like this strengthens logical thinking and problem-solving skills. #LeetCode #Java #CodingPractice #ProblemSolving #DSA
To view or add a comment, sign in
-
-
🚀 DSA in Java – Day 76 ✅ Today I solved the “Check if Binary String Has at Most One Segment of Ones” problem on LeetCode. 💡 Problem Idea: Given a binary string, we need to check whether there is at most one continuous segment of '1's in the string. 🧠 Approach: Traverse the string using a loop. Count how many segments of '1' appear. If the count becomes greater than 1, return false. Otherwise return true. ⚡ Key Concepts Practiced: String traversal While loop Character comparison Logical conditions Consistency in solving problems every day is helping me strengthen my problem-solving and logical thinking skills in Java. #DSA #Java #LeetCode #ProblemSolving #CodingJourney #WomenInTech #100DaysOfCode
To view or add a comment, sign in
-
-
Day 7/50 | #50DaysOfCode 📍 Platform: LeetCode 💻 Language: Java ✅ 414. Third Maximum Number (Easy) Today’s problem focused on finding the third distinct maximum value in an array. It helped reinforce concepts like handling duplicates and tracking multiple maximum values efficiently. 🔎 Approach: Traverse the array and track the first, second, and third distinct maximum values Skip numbers that are duplicates of already tracked maximums Update the three maximum values whenever a larger number is found If the third maximum exists, return it Otherwise, return the maximum value 📌 Example: Input: nums = [3,2,1] Output: 1 Explanation: 1st maximum = 3 2nd maximum = 2 3rd maximum = 1 This problem improved my understanding of array traversal, handling duplicates, and maintaining multiple maximum values in Java. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #Consistency #LearningJourney #50DaysOfCode #LinkedIn
To view or add a comment, sign in
-
-
Today I solved “Fibonacci Number” on LeetCode using Java. 💡 Problem Summary The Fibonacci sequence is defined as: F(0) = 0 F(1) = 1 F(n) = F(n-1) + F(n-2) We need to compute F(n). 🧠 Approach I Used (Iterative Optimization) Instead of recursion (which is slow and redundant), I used an iterative approach: Maintain two variables → previous two values Keep updating them in a loop Build the answer step by step ⚙️ Why Not Recursion? Recursion leads to repeated calculations Time complexity becomes O(2ⁿ) ❌ Iterative solution reduces it to O(n) ✅ 📊 Complexity Analysis ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) ⚡ Result ✅ Accepted ⚡ Runtime: 0 ms (Beats 100%) 📚 Key Learning Always try to optimize recursion → iteration Use variables smartly to reduce space Even simple problems teach important optimization patterns Slowly building strong fundamentals, one problem at a time 💯 Day 15 done. Let’s keep the streak alive 🔥 #DSA #LeetCode #Java #100DaysOfCode #Algorithms #ProblemSolving #CodingJourney #Consistency #LearningInPublic
To view or add a comment, sign in
-
-
Day 5/50 | #50DaysOfCode 📍 Platform: LeetCode 💻 Language: Java ✅ 290. Word Pattern (Easy) Today’s problem focused on mapping relationships between characters and words. It helped strengthen my understanding of hash-based data structures and bijection logic. 🔎 Approach: Split the string s into individual words Check if the length of the pattern matches the number of words Use a HashMap to map each character in the pattern to a word Ensure that each character maps to only one unique word Also verify that no two characters map to the same word Return true if the mapping follows the pattern, otherwise false 📌 Example: Input: pattern = "abba", s = "dog cat cat dog" Output: true Explanation: 'a' → "dog" 'b' → "cat" This problem improved my understanding of HashMap usage, string splitting, and bijection mapping logic in Java. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #Consistency #LearningJourney #50DaysOfCode #LinkedIn
To view or add a comment, sign in
-
-
Day 21/100: String Compression & Memory 📦 Today I tackled String Compression in Java (e.g., "aaabb" -> "a3b2"). The Goal: Compress a string by counting repeated characters. Example:"aaabbc" becomes "a3b2c1". If the compressed string isn't actually shorter, return the original. Key Learning: StringBuilder vs. String In Java, strings are immutable. If you add to a string in a loop, Java creates a new object every single time. To fix this, I used **StringBuilder**, which is much faster and memory-efficient for building long strings. The Strategy: 1️⃣ Iterate through the string once. 2️⃣ Keep a running count of identical consecutive characters. 3️⃣ Append the character and count to the builder. Simple logic, big performance difference. 🚀 #100DaysOfCode #Java #DSA #Strings #Optimization #Unit2 #CodingJourney #LearnInPublic
To view or add a comment, sign in
-
-
Day 33 of my DSA Journey Today I solved the problem “Reverse Vowels of a String” using Java. In this problem, the goal is to reverse only the vowels in a string while keeping all other characters in their original positions. To solve this efficiently, I used the Two Pointer approach. Key idea: • Convert the string into a character array. • Use two pointers (left and right). • Move the left pointer forward until a vowel is found. • Move the right pointer backward until a vowel is found. • Swap the vowels. • Continue until the pointers meet. This approach helps solve the problem in O(n) time complexity with O(1) extra space. Concepts practiced today: • Two Pointer Technique • String manipulation in Java • Character array operations Consistent practice is helping me strengthen my problem-solving skills step by step. #Day33 #DSA #Java #CodingJourney #ProblemSolving #LeetCode
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