🚀 Inverted Star Pattern Using Nested Loops in Java After building a normal star pattern, today I implemented the inverted star pattern using the same nested loop logic — but with a different approach in controlling the loop conditions. Pattern Output: * * * * * * * * * * 💡 What this taught me: ✔ How changing loop conditions changes the entire structure ✔ Better understanding of outer & inner loop coordination ✔ Stronger grip on pattern-based logic building ✔ Thinking in reverse logic (important for DSA) Small pattern problems like this may look simple, but they seriously improve logical thinking and control over loops. Step by step, building strong fundamentals in Java. 💻🔥 #Java #DSA #CodingPractice #ProgrammingJourney #LearningInPublic #StudentDeveloper
Inverted Star Pattern in Java with Nested Loops
More Relevant Posts
-
Day 49 of #100DaysOfLeetCode 💻✅ Solved #387. First Unique Character in a String problem in Java. Approach: • Created an array of size 26 to store the frequency of each character • Traversed the string and counted how many times each character appears • Traversed the string again to find first character with frequency equal to 1 • Returned the index of that character • If no unique character is found, returned -1 Performance: ✓ Runtime: 6 ms (Beats 84.58% submissions) ✓ Memory: 47.16 MB (Beats 36.29% submissions) Key Learning: ✓ Practiced using frequency arrays for string problems ✓ Learned how counting characters helps find unique elements efficiently ✓ Strengthened understanding of string traversal and indexing Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 27 / 180 – DSA with Java 🚀 📘 Topic Covered: Strings & Reverse Traversal 🧩 Problem Solved: Length of Last Word Problem: Given a string containing words separated by spaces, find the length of the last word. Approach: Started traversing the string from the end, skipped trailing spaces first, and then counted characters until encountering another space or reaching the beginning of the string. Key Learning: ✔️ Efficient reverse traversal in strings ✔️ Handling edge cases like trailing spaces ✔️ Writing simple yet optimized string logic If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Strings #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Day 61 of #100DaysOfLeetCode 💻✅ Solved #541. Reverse String II problem in Java. Approach: • Converted the string into a character array • Traversed the array in steps of 2k • For every segment, reversed the first k characters • Used two-pointer technique to perform in-place reversal • Math.min() to handle cases where remaining characters are less than k Performance: ✓ Runtime: 2 ms (Beats 16.04% submissions) ✓ Memory: 44.80 MB (Beats 73.53% submissions) Key Learning: ✓ Practiced handling strings with fixed pattern intervals ✓ Improved control over indexing and boundaries ✓ Strengthened in-place modification techniques Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #TwoPointers #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 55 of #100DaysOfLeetCode 💻✅ Solved #434. Number of Segments in a String problem in Java. Approach: • Initialized a counter to track number of words (segments) • Traversed the string character by character • Checked for non-space characters • If the current character is not a space and either it is the first character or the previous character is a space, incremented the count • This ensures counting only the starting of each word Performance: ✓ Runtime: 0 ms (Beats 100% submissions) 🚀 ✓ Memory: 41.83 MB (Beats 99.81% submissions) Key Learning: ✓ Practiced string traversal without using extra space ✓ Learned how to identify word boundaries efficiently ✓ Improved logic building for handling spaces and edge cases Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #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 98 - #100DaysOfCode Today’s problem was all about string comparison and operations simulation in Java. 💡 Problem Insight: Given a list of operations like "++X", "X++", "--X", "X--", we need to compute the final value of X after performing all operations. ⚠️ One key learning today: In Java, always use .equals() for string comparison instead of ==. Using == compares references, not actual content — a very common mistake! 🧠 Approach: Initialize x = 0 Traverse through each operation Increment or decrement based on the operation string 📌 What I Improved Today: Better understanding of string handling in Java Avoiding common pitfalls in comparisons Writing cleaner conditional logic #Java #CodingJourney #LeetCode #100DaysOfCode #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Today I implemented Array Reversal in Java using the Two-Pointer Technique! 🔄 Logic: ∙ Set left = 0 and right = arr.length - 1 ∙ Swap elements at both ends ∙ Move pointers inward until they meet ✅ Input: {1, 2, 3, 4, 5} ✅ Output: 5 4 3 2 1 💡 Why Two-Pointer? Instead of using extra space, we swap in-place — making it O(n) time and O(1) space! No extra array needed. Just two pointers doing the work. 💪 Every small concept I practice brings me one step closer to DSA mastery. Keep building. Keep learning. 🙌 #100daysofcode #dsa #java #program #array #problem #leetcode #javadeveloper #learning
To view or add a comment, sign in
-
-
Day 56 of #100DaysOfLeetCode 💻✅ Solved #205. Isomorphic Strings problem in Java. Approach: • Used two arrays to track character mappings for both strings • Traversed both strings simultaneously • Checked if the mapping values at current characters are equal • If not equal, returned false (mapping mismatch) • Updated both arrays with the current index + 1 • This ensures consistent one-to-one mapping between characters Performance: ✓ Runtime: 8 ms (Beats 72.19% submissions) ✓ Memory: 44.16 MB (Beats 22.15% submissions) Key Learning: ✓ Learned how to maintain mapping consistency between two strings ✓ Practiced using arrays for character indexing ✓ Strengthened understanding of string pattern matching problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 28 / 180 – DSA with Java 🚀 📘 Topic Covered: Strings & Sliding Window 🧩 Problem Solved: Divisor Substrings Problem: Given an integer num and an integer k, find the number of substrings of length k from the digits of num such that the substring value divides num. Approach: Converted the number to a string and used a sliding window of size k to extract substrings. Each substring was converted back to an integer and checked whether it divides the original number. Key Learning: ✔️ Applying sliding window technique on strings ✔️ Converting between numeric and string representations ✔️ Handling edge cases like division by zero If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Strings #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
💻 Practicing Binary to Decimal Conversion using Java Today I worked on converting a binary number into its decimal equivalent using logic and iteration. 🔍 Key Learnings: Understanding how binary digits map to powers of 2 Strengthening loop and mathematical logic Improving problem-solving skills step by step Instead of just memorizing, I focused on understanding the logic deeply and practicing with different inputs. 📌 Example: Binary: 1010 → Decimal: 10 Consistency + Practice = Progress 🚀 #Java #DSA #CodingJourney #Programming #100DaysOfCode #LearnToCode #ProblemSolving #DeveloperJourney #CodingPractice #TechSkills
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