🚀 𝗗𝗮𝘆 𝟮𝟴 – 𝗝𝗮𝘃𝗮 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 𝗦𝗼𝗹𝘃𝗶𝗻𝗴 & 𝗗𝗦𝗔 𝗝𝗼𝘂𝗿𝗻𝗲𝘆 Consistency builds capability. Today marks Day 28 of my continuous practice in Java Problem Solving and Data Structures & Algorithms. Each day is helping me strengthen my fundamentals and improve my logical thinking. 🔹 Concepts Practiced Today - Binary Search – understanding how it significantly reduces time complexity compared to Linear Search - Floor of a Number - Ceil of a Number - Finding the Span of elements - Leader in an Array 🧪 Practice Test Focus Worked on array and sub-array based logical problems such as: - Printing all elements whose index position sum is divisible by m1 and m2 - Writing a program to identify subarrays where the difference between the maximum and minimum element equals k These exercises are helping me develop a deeper understanding of algorithm efficiency, edge cases, and array traversal logic. 💡 Every problem solved is another step toward becoming a stronger developer. #Java #DSA #ProblemSolving #LearningInPublic #ProgrammingJourney #ComputerScience #DeveloperGrowth
Java Problem Solving Day 28: Binary Search & DSA Journey
More Relevant Posts
-
🚀 DAY 64/150 — SIMULATING A QUEUE PROCESS! 🚀 Day 64 of my 150 Days DSA Challenge in Java and today I solved an interesting problem based on queue simulation and logical observation 💻🧠 📌 Problem Solved: Time Needed to Buy Tickets 📌 LeetCode: #2073 📌 Difficulty: Easy–Medium The problem describes a queue of people where each person wants to buy a certain number of tickets. Each second, the person at the front buys one ticket and moves to the end of the queue if they still need more tickets. The goal is to calculate the total time required for the person at index k to finish buying their tickets. 🔹 Approach Used Instead of fully simulating the queue step by step, I used logical observation: • People before index k can buy up to tickets[k] tickets • People after index k can buy up to tickets[k] - 1 tickets • Sum these contributions to calculate the total time directly This avoids unnecessary queue simulation and leads to a cleaner solution. ⏱ Complexity Time Complexity: O(n) Space Complexity: O(1) 🧠 What I Learned • Some simulation problems can be optimized by analyzing patterns instead of simulating every step • Understanding the behavior of queue operations helps simplify the logic • Observational optimization often turns a brute-force simulation into a linear solution 💡 Key Takeaway This problem taught me that not every queue problem needs an actual queue implementation — sometimes understanding the process mathematically can produce a more efficient solution. ✅ Day 64 completed 🚀 86 days to go 🔗 Java Solution on GitHub: 👉 https://lnkd.in/gTanCWzM 💡 Good problem solving is about recognizing patterns, not just writing loops. #DSAChallenge #Java #LeetCode #Queue #ProblemSolving #150DaysOfCode #CodingJourney #InterviewPrep #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Day 76/90 – Beyond the Basics: Advanced Heap Applications I spent today exploring the practical side of Priority Queues in Java. While Heaps are often taught as simple "min/max" structures, today’s practice showed me how they are the backbone of efficient scheduling and data merging. Highlights from today’s 18-problem sprint: ✅ Task Scheduling: Prioritizing tasks based on dynamic importance using custom objects. ✅ Frequency Sorting: Using Map + PriorityQueue to rank data by occurrence. ✅ Geometric Problems: Calculating K-closest points to the origin using Euclidean distance logic. ✅ Data Stream Analysis: Implementing a real-time median finder using a dual-heap (Min-Max) balancing approach. Technical Deep-Dive: Today wasn't just about pq.add(). I focused heavily on Custom Comparators to handle complex sorting logic: Multi-level Sorting: Ordered students by marks (descending) and names (ascending). Efficient Merging: Used Heaps to merge K sorted arrays and linked lists, reducing time complexity significantly compared to naive sorting. Optimization: Solved the "Nearly Sorted Array" problem and "Connect N Ropes" using a Greedy approach to minimize total cost. The more I practice, the more I realize that DSA isn't just about passing interviews—it's about writing code that scales. #90DaysOfDSA #JavaProgramming #DataStructures #SoftwareEngineering #ProblemSolving #TechCommunity #RiteshWaghCodes #Heaps
To view or add a comment, sign in
-
📘 DSA Journey — Day 29 Today’s focus: Binary Search on answer space. Problem solved: • Find Peak Element (LeetCode 162) Concepts used: • Binary Search • Observing slope / trend • Search space reduction Key takeaway: The goal is to find a peak element (an element greater than its neighbors). Instead of checking all elements, we use binary search by observing the slope: • If nums[mid] < nums[mid + 1] → we are on an increasing slope, so a peak must exist on the right side • Else → we are on a decreasing slope, so a peak lies on the left side (including mid) By following this logic, we eliminate half of the search space each time and find a peak in O(log n) time. The key insight is: A peak is guaranteed to exist, and the direction of slope helps guide the search. Continuing to strengthen binary search intuition and consistency in problem solving. #DSA #Java #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
🔥 Day 532 of #750DaysOfCode 🔥 ✅ Solved: 1622. Fancy Sequence (Hard) Today’s problem was a tough one! This question required designing an API that supports multiple operations on a sequence efficiently using modular arithmetic, lazy updates, and modular inverse. Instead of updating every element for each operation, I used a mathematical transformation approach with two variables to keep track of multiplication and addition globally. This helped achieve O(1) per operation. 💡 Key Concepts Used: Modular Arithmetic (10^9 + 7) Fast Power (Binary Exponentiation) Modular Inverse Lazy Transformation Technique Design Data Structure 🚀 Approach: Maintain two variables a and b to represent transformation Store values in normalized form Use modular inverse while appending Compute actual value during getIndex 💻 Language: Java 💻 Topic: Design + Math + Hashing + Modular Arithmetic Hard problems like this really improve problem-solving skills and understanding of mathematical optimizations. 🔗 LeetCode Problem: Fancy Sequence #leetcode #java #datastructures #algorithms #codingchallenge #100daysofcode #programming #softwareengineer #backenddeveloper #dsa #750daysofcode
To view or add a comment, sign in
-
-
Classical Backtracking Problem with a Classical Approach Solved Word Search (LeetCode 79) using a clean and intuitive DFS + Backtracking strategy Approach (Simple & Clear): •Start from every cell that matches the first character of the word. •Use DFS (Depth-First Search) to explore all 4 directions (up, down, left, right). •Mark the current cell as visited (by replacing it temporarily) to avoid revisiting. •If the full word is matched → return true immediately. •Backtrack by restoring the cell when the path doesn’t work. Key Insight: We explore all possible paths, but prune early when characters don’t match — this keeps the solution efficient. ⏱️ Time Complexity: 👉 O(m × n × 4^L) •m × n → starting points •4^L → exploring 4 directions for each character of length L 📌 Space Complexity: 👉 O(L) (recursion stack) 🔥 Clean recursion + smart backtracking = problem cracked! #DSA #Backtracking #LeetCode #CodingInterview #Java #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 70 of DSA Problem Solving Today I solved the Complement of Base 10 Integer problem on LeetCode. 🔹 Problem Idea: The task is to find the complement of a given integer by flipping all bits in its binary representation. If a bit is 0, it becomes 1, and if it is 1, it becomes 0. 🧠 Key Learning: Today I learned how bit manipulation can simplify problems involving binary numbers. By creating a mask with all 1s equal to the length of the number’s binary representation, we can easily compute the complement using the XOR operation. 💡 Concepts Practiced: Bit Manipulation Bit Masking XOR Operation Binary Representation of Numbers ⏱ Time Complexity: O(log n) — because the algorithm processes the number of bits in the integer. 🔥 Real Journey Behind the Solution: While solving this problem, I explored how binary operations work internally. Understanding how to build a mask dynamically helped me solve the problem efficiently without converting the number into a string. Consistency in small steps is what builds strong problem-solving skills over time. 💪 #DSA #Java #LeetCode #CodingChallenge #ProblemSolving #BitManipulation #LearningInPublic 🚀
To view or add a comment, sign in
-
-
Day 61 of My DSA Journey Today I solved the Subsets problem using the Backtracking technique. 🔹 Problem: Given an integer array nums, return all possible subsets (the power set). 🔹 Key Idea: Instead of trying to generate subsets directly, I used backtracking to explore every possible combination. 💡 Approach: Start with an empty subset. At each step, add the current subset to the result. Try including each element one by one. Recursively explore further subsets. Backtrack by removing the last element to explore other possibilities. 🔁 This approach systematically explores every possible subset using a decision tree. 📊 Time Complexity: O(n × 2ⁿ) — because each element can either be included or excluded. ✨ What I Learned: Backtracking is powerful for solving combinatorial problems. The pattern of choose → explore → unchoose is very important. 💻 Practicing problems like this helps strengthen recursion and problem-solving skills. #Day61 #DSA #Backtracking #Java #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 DSA Problem Solved: Container With Most Water Today I worked on the classic “Container With Most Water” problem, a well-known challenge that helps strengthen understanding of the Two Pointer technique and array optimization. 🔍 Problem Overview We are given an array where each element represents the height of a vertical line. The goal is to identify two lines that together form a container capable of holding the maximum amount of water. The water stored depends on the distance between the lines (width) and the minimum height of the two lines. 💡 Approach Used Instead of checking every possible pair (which would take O(n²) time), the problem can be solved efficiently using the Two Pointer approach: Start with one pointer at the beginning of the array and another at the end. Calculate the water that can be stored between the two lines. Move the pointer pointing to the smaller height, since the container height is limited by the shorter line. Continue updating the maximum area until the pointers meet. ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(1) 🎯 Key Learning This problem highlights how smart pointer movement and observation of constraints can reduce time complexity from quadratic to linear. It is a great example of optimizing brute-force solutions using efficient patterns. #DSA #Algorithms #Java #ProblemSolving #CodingPractice #TwoPointers #LeetCode #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 𝗗𝗮𝘆 - 35/60 Problem: Missing and Repeating Number 🔍 Learned: Given numbers from 1 to n, one number is missing and one is repeating. Used a HashMap to count frequencies and identify the duplicate (count > 1) and missing (not present). 😅 Struggles: Initially thought about mathematical formulas, but it felt complex to manage both missing and repeating together. Using a map made the logic straightforward and easy to debug. 🧠 Key Learning: Counting frequency is a reliable way to detect anomalies in arrays. Though it uses extra space, it simplifies implementation and avoids tricky math. 📦 Concepts Used: #Arrays #HashMap #Counting #Frequency #TimeComplexity #DSA Clear logic first, optimization later. Building confidence step by step. 🚀 #Java #CodingJourney #ProblemSolving #DSA
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟒𝟗 – 𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 | 𝐀𝐫𝐫𝐚𝐲𝐬 🚀 Today’s problem focused on checking whether a string can be segmented into valid dictionary words. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐞𝐝 • Word Break 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 – 𝐃𝐅𝐒 + 𝐌𝐞𝐦𝐨𝐢𝐳𝐚𝐭𝐢𝐨𝐧 • Converted the word list into a HashSet for fast lookup • Used recursion to try breaking the string into prefixes • If prefix exists in dictionary, recursively check the remaining string • Stored results in a memo map to avoid recomputation This avoids exponential re-checking of the same substrings. 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬 • Memoization helps optimize recursive solutions • Breaking problems into smaller substrings is a common pattern • HashSet improves lookup efficiency • DP problems often start with recursion and get optimized 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 • Time: O(n²) (with memoization) • Space: O(n) 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 When recursion feels slow, adding memoization can transform it into an efficient solution. 49 days consistent 🚀 On to Day 50. #DSA #Arrays #DynamicProgramming #Recursion #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
Explore related topics
- Build Problem-Solving Skills With Daily Coding
- Tips for Continuous Improvement in Problem Solving
- How to Develop Structured Problem Solving Skills
- Logical Reasoning Skills
- Problem-Solving Skills in System Debugging
- Tips for Problem-Solving with Clarity
- Approaches to Array Problem Solving for Coding Interviews
- Leetcode Problem Solving Strategies
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