🚀 Day 10 / 180 – DSA with Java 🚀 📘 Topic Covered: Loops & Conditional Logic 🧩 Problem Solved: Sum of Multiples Problem: Given an integer n, calculate the sum of all numbers from 1 to n that are divisible by 3, 5, or 7. Approach: Iterated from 1 to n and checked divisibility conditions. If a number was divisible by 3, 5, or 7, added it to the running sum. Key Learning: ✔️ Strengthening fundamentals with loops and conditions ✔️ Writing clean and readable logic ✔️ Importance of handling multiple conditions efficiently If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #ProblemSolving #Consistency
Java DSA Day 10: Loops & Conditional Logic with Divisibility
More Relevant Posts
-
🚀 Day 13 / 180 – DSA with Java 🚀 📘 Topic Covered: Loops & Conditional Logic 🧩 Problem Solved: FizzBuzz Problem: For numbers from 1 to n, return: • “Fizz” if divisible by 3 • “Buzz” if divisible by 5 • “FizzBuzz” if divisible by both • Otherwise, return the number itself Approach: Iterated from 1 to n, checked divisibility conditions, built the appropriate string dynamically, and stored the result in a list. Key Learning: ✔️ Strengthening control flow fundamentals ✔️ Handling multiple conditions cleanly ✔️ Writing simple yet structured logic If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 18 / 180 – DSA with Java 🚀 📘 Topic Covered: Strings & Carry-Based Addition 🧩 Problem Solved: Add Binary Problem: Given two binary strings, return their sum as a binary string. Approach: Traversed both strings from right to left, added corresponding digits along with carry, and built the result step by step. Used a string builder and reversed the final result to get the correct order. Key Learning: ✔️ Handling carry logic in string-based arithmetic ✔️ Simulating manual binary addition programmatically ✔️ Managing different string lengths efficiently 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 34 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Basic Construction 🧩 Problem Solved: Concatenation of Array Problem: Given an integer array nums, create a new array that contains the elements of nums twice in sequence. Approach: Created a new array with double the size of the original array and filled the first half with the original elements, then copied the same elements again into the second half. Key Learning: ✔️ Practicing array construction and indexing ✔️ Understanding how to manipulate array sizes ✔️ Writing clean logic for simple transformation problems If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Arrays #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 16 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Carry Handling 🧩 Problem Solved: Plus One Problem: Given a number represented as an array of digits, increment the number by one and return the updated array. Approach: Started from the last digit and handled the carry carefully. If the digit was less than 9, incremented it directly. If it was 9, set it to 0 and continued moving left to handle the carry. If all digits were 9, created a new array with an extra leading 1. Key Learning: ✔️ Handling carry propagation in arrays ✔️ Managing edge cases like all 9s ✔️ Thinking about number representation logically If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Arrays #ProblemSolving #Consistency
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 12 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Sorting 🧩 Problem Solved: Number Game Problem: Given an array, sort it and swap every pair of adjacent elements to form the required output pattern. Approach: First sorted the array to organize elements in ascending order. Then iterated in steps of two and swapped adjacent elements to achieve the desired arrangement. Key Learning: ✔️ Combining sorting with index-based manipulation ✔️ Understanding pattern formation in arrays ✔️ Importance of careful iteration while swapping elements If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Arrays #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 22 / 180 – DSA with Java 🚀 📘 Topic Covered: Hashing & Sequence Detection 🧩 Problem Solved: Longest Consecutive Sequence Problem: Given an unsorted array of integers, find the length of the longest consecutive elements sequence in O(n) time. Approach: Stored all elements in a HashSet for O(1) lookups. For each number, only started counting if it was the beginning of a sequence (i.e., the previous number was not present). Then extended the sequence forward to find its length. Key Learning: ✔️ Using HashSet for efficient lookups ✔️ Identifying sequence starting points to avoid redundancy ✔️ Achieving O(n) time complexity for an otherwise sorting-based problem If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Hashing #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 14 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Sorted-Rotation Logic 🧩 Problem Solved: Check if Array is Sorted and Rotated Problem: Determine whether a given array is sorted in non-decreasing order and then possibly rotated. Approach: Traversed the array and counted how many times the order decreases (where the current element is smaller than the previous one). If the count of such “break points” is at most one (including the circular check between last and first elements), the array satisfies the condition. Key Learning: ✔️ Understanding sorted array properties ✔️ Handling circular array comparisons ✔️ Solving rotation-based problems efficiently in O(n) time If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Arrays #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 33 / 180 – DSA with Java 🚀 📘 Topic Covered: Arrays & Index Manipulation 🧩 Problem Solved: Shuffle the Array Problem: Given an array in the form [x1, x2, ..., xn, y1, y2, ..., yn], rearrange it to [x1, y1, x2, y2, ..., xn, yn]. Approach: Used two pointers to track elements from the first and second halves of the array, then alternately placed them into a new array to achieve the required shuffle pattern. Key Learning: ✔️ Managing multiple pointers in array problems ✔️ Practicing index-based rearrangement ✔️ Maintaining correct ordering while constructing a new array If you’re also preparing for DSA, let’s connect and learn together 🤝 #DSA #Java #180DaysOfCode #LearningInPublic #Arrays #ProblemSolving #Consistency
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
-
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