Day 65 of #100DaysOfLeetCode 💻✅ Solved “Majority Frequency Group” problem in Java. Approach: • Created a frequency array of size 26 for all characters • Counted occurrences of each character in the string • For each unique frequency, counted how many characters share that frequency • Selected the frequency with the highest group size • In case of tie, chose the higher frequency • Built the result string with characters having the selected frequency Performance: ✓ Runtime: 5 ms (Beats 57.84% submissions) ✓ Memory: 44.51 MB (Beats 72.88% submissions) Key Learning: ✓ Practiced frequency grouping techniques ✓ Learned how to handle tie-breaking conditions ✓ Strengthened logic building with nested loops and conditions Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #Hashing #ProblemSolving #CodingJourney #100DaysOfCode
Solved Majority Frequency Group in Java with Frequency Array
More Relevant Posts
-
Day 89 of #100DaysOfLeetCode 💻✅ Solved #15. 3Sum problem in Java. Approach: • Sorted the array first • Fixed one element and used Two Pointers for the rest • Skipped duplicates to avoid repeated triplets • Adjusted pointers based on sum comparison Performance: ✓ Runtime: 30 ms (Beats 87.77% submissions) ✓ Memory: 59.02 MB (Beats 77.30% submissions) Key Learning: ✓ Mastered Two Pointer technique with sorting ✓ Learned handling duplicates efficiently ✓ Improved problem-solving for combination-based problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #TwoPointers #Arrays #Sorting #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 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 90 of #100DaysOfLeetCode 💻✅ Solved #42. Trapping Rain Water problem in Java. Approach: • Used Two Pointer technique • Maintained leftMax and rightMax boundaries • Calculated trapped water based on smaller side • Accumulated water while traversing Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) 🚀 ✓ Memory: 47.70 MB (Beats 72.36% submissions) Key Learning: ✓ Mastered Two Pointer approach for complex problems ✓ Learned optimal water trapping strategy ✓ Improved understanding of boundary-based calculations Learning one problem every single day 🚀 #Java #LeetCode #DSA #TwoPointers #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 70 of #100DaysOfLeetCode 💻✅ Solved #3136. Valid Word problem in Java. Approach: • Checked if the word length is at least 3 • Traversed each character in the string • Ensured all characters are either letters or digits • Checked for presence of at least one vowel • Checked for presence of at least one consonant • Returned true only if all conditions are satisfied Performance: ✓ Runtime: 1 ms (Beats 99.62% submissions) 🚀 ✓ Memory: 43.08 MB (Beats 93.16% submissions) Key Learning: ✓ Practiced string validation with multiple conditions ✓ Learned efficient use of built-in character functions ✓ Strengthened logic building for edge case handling Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Solved LeetCode 17 – Letter Combinations of a Phone Number using backtracking in Java. Approach: Mapped each digit (2–9) to its corresponding characters using a simple array for O(1) access. Then used backtracking to build combinations digit by digit. For every digit: Pick each possible character Append → explore next digit → backtrack Key idea: Treat it like a tree of choices, where each level represents a digit and branches represent possible letters. Key learnings: Backtracking = build → explore → undo StringBuilder helps avoid unnecessary string creation Problems like this are about systematic exploration of choices Time Complexity: O(4^n * n) Space Complexity: O(n) recursion stack + output Consistent DSA practice is strengthening pattern recognition day by day. #Java #DSA #Backtracking #LeetCode #CodingInterview #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Exploring Method Overloading with Varargs in Java Today, I worked on an interesting Java problem that helped me strengthen my understanding of Compile-Time Polymorphism and Varargs (Variable Arguments). 🔹 Problem Statement: Design a VarargsCalculator class with overloaded methods to calculate the sum of: Multiple integers Multiple double values 🔹 Key Concepts Used: ✔ Method Overloading ✔ Varargs (int..., double...) ✔ Switch-case for dynamic method selection ✔ For-each loop for efficient iteration 🔹 Learning Outcome: This problem clearly demonstrates how Java allows the same method name to handle different types and number of inputs, depending on the parameters passed. It also shows how varargs simplify handling multiple inputs without explicitly creating arrays. 💡 Key Insight: Varargs in Java internally behave like arrays, making code more flexible and readable. 🔹 Sample Output: Sum of integers: 10 Sum of doubles: 7.0 📌 Practicing such problems is helping me improve my problem-solving skills and deepen my understanding of core Java concepts. #Java #CoreJava #MethodOverloading #Varargs #Programming #Coding #100DaysOfCode #DeveloperJourney #JavaDeveloper #LearningInPublic
To view or add a comment, sign in
-
-
Understanding the difference between shallow copy and deep copy in Java really changed how I think about object handling and memory. A shallow copy duplicates the reference — meaning changes in one object can unexpectedly affect another. On the other hand, a deep copy creates an entirely independent object with its own memory allocation. This concept might seem small at first, but it becomes critical when working with complex data structures, real-world applications, and avoiding unintended side effects. Key takeaway: Always be clear whether you're copying data or just references. #Java #Programming #Learning #DSA #SoftwareDevelopment
To view or add a comment, sign in
-
-
📅 Day 45 of My Learning Journey Today, I explored two important concepts in Java: String Class and StringBuffer. 🔹 String Class Strings are immutable, meaning once an object is created, it cannot be changed. Any modification results in the creation of a new object. Widely used for safe and secure data handling. 🔹 StringBuffer StringBuffer is mutable, meaning it allows changes without creating new objects. It is thread-safe (synchronized), making it suitable for multi-threaded environments. Provides methods like append(), insert(), and reverse() for efficient string manipulation. 💡 Key Takeaway: Use String when data should remain constant, and StringBuffer when frequent modifications are required, especially in multi-threaded applications. 📌 Understanding the difference between immutability and mutability helps in writing optimized and efficient Java programs! #Day45 #Java #StringClass #StringBuffer #Programming #LearningJourney #TechSkills
To view or add a comment, sign in
-
-
Day 80 of #100DaysOfLeetCode 💻✅ Solved #560. Subarray Sum Equals K problem in Java. Approach: • Used Prefix Sum with HashMap • Tracked cumulative sum while iterating • Checked if (sum - k) exists in map • Updated count based on previous occurrences Performance: ✓ Runtime: 23 ms (Beats 94.04% submissions) 🚀 ✓ Memory: 48.74 MB (Beats 63.25% submissions) Key Learning: ✓ Mastered Prefix Sum technique ✓ Learned efficient subarray counting using HashMap ✓ Improved understanding of cumulative sum patterns Learning one problem every single day 🚀 #Java #LeetCode #DSA #PrefixSum #HashMap #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
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