Day 41 of #100DaysOfLeetCode 💻✅ Solved #242. Valid Anagram problem in Java. Approach: • Converted both strings to lowercase to ensure case-insensitive comparison • Converted the strings into character arrays • Sorted both arrays using Arrays.sort() • Compared the sorted arrays using Arrays.equals() • If both arrays match, the strings are anagrams Performance: ✓ Runtime: 11 ms (Beats 28.32% submissions) ✓ Memory: 46.83 MB (Beats 8.28% submissions) Key Learning: ✓ Practiced string manipulation and character array handling in Java ✓ Understood how sorting helps in comparing character frequencies ✓ Strengthened problem-solving skills for string-based problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #ProblemSolving #CodingJourney #100DaysOfCode
Java LeetCode 242: Valid Anagram Solution
More Relevant Posts
-
Day 44 of #100DaysOfLeetCode 💻✅ Solved Very Simple #169. Majority Element problem in Java. Approach: • Sorted the given array using Arrays.sort() • Observed that the majority element appears more than n/2 times • After sorting, the majority element will always be present at index n/2 • Returned the element at nums[n/2] Performance: ✓ Runtime: 7 ms (Beats 42.86% submissions) ✓ Memory: 55.96 MB (Beats 16.21% submissions) Key Learning: ✓ Understood how sorting can help identify the majority element ✓ Learned the property that the majority element always occupies the middle position after sorting ✓ Practiced array manipulation and problem solving in Java Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 66 of #100DaysOfLeetCode 💻✅ Solved #3427. Sum of Variable Length Subarrays problem in Java. Approach: • Iterated through each index of the array • Determined the starting index using i - nums[i] • Ensured the start index does not go below 0 • Calculated sum of elements from start to current index i • Added each subarray sum to the total Performance: ✓ Runtime: 1 ms (Beats 99.90% submissions) ✓ Memory: 45.22 MB (Beats 56.30% submissions) Key Learning: ✓ Practiced handling variable-length subarrays ✓ Improved understanding of index-based range calculations ✓ Strengthened nested loop logic for array problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #PrefixSum #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 62 of #100DaysOfLeetCode 💻✅ Solved #219. Contains Duplicate II problem in Java. Approach: • Used two nested loops to compare elements within range k • For each element, checked next k elements • If any duplicate is found within distance k, returned true • If no such pair exists, returned false Key Learning: ✓ Practiced checking duplicates within a given range ✓ Strengthened understanding of array traversal with conditions ✓ Learned the importance of optimizing nested loop solutions Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 64 of #100DaysOfLeetCode 💻✅ Solved #724. Find Pivot Index problem in Java. Approach: • Calculated the total sum of the array • Maintained a variable left to track left sum • For each index, computed right sum as total - left - nums[i] • Compared left and right sums • If both are equal, returned the index as pivot • Updated left sum by adding current element Performance: ✓ Runtime: 1 ms (Beats 98.68% submissions) 🚀 ✓ Memory: 47.58 MB (Beats 32.00% submissions) Key Learning: ✓ Learned prefix sum technique for efficient calculations ✓ Practiced reducing time complexity from O(n²) to O(n) ✓ Strengthened understanding of array traversal and sum logic Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #PrefixSum #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 63 of #100DaysOfLeetCode 💻✅ Solved #2085. Count Common Words With One Occurrence problem in Java. Approach: • Iterated through each word in the first array • Avoided duplicate checks by ensuring each word is processed only once • Counted occurrences of the current word in both arrays • If the word appears exactly once in both arrays, incremented the result • Returned the final count Performance: ✓ Runtime: 88 ms (Beats 7.45% submissions) ✓ Memory: 46.06 MB (Beats 93.07% submissions) Key Learning: ✓ Practiced handling duplicates and frequency counting ✓ Improved understanding of string comparison in arrays ✓ Learned importance of optimizing nested loop solutions Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
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
-
-
🚀 DSA in Java — Day 78 📌 Problem Solved: Binary Tree Level Order Traversal Today I solved the Binary Tree Level Order Traversal problem on LeetCode using Breadth First Search (BFS) with a Queue. In this problem, we traverse the binary tree level by level from left to right. 🔹 Approach Used: Used a Queue data structure Added the root node to the queue Processed nodes level by level Stored each level's values inside a list Added the list to the final result 🔹 Key Concepts Practiced: ✔ Binary Trees ✔ Breadth First Search (BFS) ✔ Queue in Java ✔ Level-wise traversal This problem helped me understand how queues are used to process nodes level-wise in trees, which is very useful in many tree problems. Consistent practice is making tree problems much clearer day by day. 💻 Language: Java 📚 Platform: LeetCode #DSA #Java #BinaryTree #LeetCode #CodingJourney #WomenInTech #100DaysOfCode
To view or add a comment, sign in
-
-
Day 46 of #100DaysOfLeetCode 💻✅ Solved #374. Guess Number Higher or Lower problem in Java. Approach: • Used Binary Search to efficiently guess the number. • Calculated mid using low + (high - low) / 2 to avoid overflow. • Used the guess(mid) API to check if the number is higher, lower, or correct. • Updated the search range accordingly until the number was found. Performance: ✓ Runtime: 0 ms (Beats 100% submissions) 🚀 ✓ Memory: 41.68 MB (Beats 97.84% submissions) Key Learning: ✓ Practiced implementing binary search on a real problem ✓ Learned how to safely calculate mid to prevent integer overflow ✓ Strengthened problem-solving skills with search algorithms Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 34/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 709. To Lower Case Used ASCII manipulation to convert uppercase letters to lowercase by adding 32, without using built-in functions. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) Strengthening understanding of character encoding and string manipulation basics. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 43 of #100DaysOfLeetCode 💻✅ Solved #100. Same Tree problem in Java. Approach: • Used recursion to compare both binary trees simultaneously • If both nodes are null, returned true • If one node is null and the other is not, returned false • Checked whether the values of both nodes are equal • Recursively compared the left subtrees and right subtrees Performance: ✓ Runtime: 0 ms (Beats 100% submissions) 🚀 ✓ Memory: 43.10 MB (Beats 30.15% submissions) Key Learning: ✓ Practiced recursive traversal of binary trees ✓ Learned how to compare two trees node by node ✓ Strengthened understanding of tree recursion logic Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinaryTrees #ProblemSolving #CodingJourney #100DaysOfCode
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