🚀 100 Days of Code Day -27 LeetCode Problem solved- Divide Two Integers Solved this interesting problem where division is performed without using multiplication, division, or mod operators. 💡 Key Learnings: Used bit manipulation (left shift) to optimize repeated subtraction Handled edge cases like overflow (Integer.MIN_VALUE) Achieved efficient solution with O(log n) complexity 📌 This problem really strengthens understanding of low-level operations and optimization techniques. Always fascinating to see how basic operations can be built from scratch! #LeetCode #Java #DSA #CodingInterview #ProblemSolving
Divide Integers without Multiplication or Division
More Relevant Posts
-
Day 101 - LeetCode Journey Solved LeetCode 856: Score of Parentheses ✅ Looks tricky at first, but turns out to be a neat pattern problem. Instead of using a stack, used depth tracking + bit manipulation to calculate score efficiently. Core idea: Every "()" contributes 2^depth So just track depth and add score at the right moment. Key learnings: • Understanding pattern inside parentheses • Using depth instead of extra space • Bit manipulation for optimization ⚡ • Clean O(n) solution without stack ✅ All test cases passed ⚡ O(n) time | O(1) space Simple logic, powerful result 💡 #LeetCode #DSA #Stack #BitManipulation #Java #CodingJourney #ProblemSolving #InterviewPrep
To view or add a comment, sign in
-
-
🚀 Day 28/100 – #100DaysOfCode Today’s problem: Reverse Linked List (LeetCode 206) 💡 What I learned: How to reverse a singly linked list using an iterative approach Managing pointers efficiently (prev, curr, next) Understanding how links change direction step by step 🧠 Key Idea: Instead of creating a new list, we reverse the links in-place: Store next node Reverse current pointer Move forward 📊 Complexity: Time: O(n) Space: O(1) Staying consistent, one problem at a time... #Day28 #100DaysOfCode #LeetCode #DSA #LinkedList #Java #CodingJourney #ProblemSolving #TechSkills
To view or add a comment, sign in
-
-
Solved one of the most interesting problems : Subarray Sum Equals K 💡 Key Takeaway: Instead of checking every subarray, tracking prefix sums helps directly identify valid subarrays in an optimized way. 👉 Key Insight: If (prefixSum - k) has already appeared, it means we found a subarray with sum = k. 📊 Time Complexity: O(n) 📦 Space Complexity: O(n) 🔍 What made it interesting? Understanding how previously seen sums help us avoid rework and directly count valid subarrays. Every day I realize: Consistency and clarity of concepts matter more than just solving problems. 💪 #DSA #Java #LeetCode #CodingJourney #BackendDeveloper #SoftwareEngineering
To view or add a comment, sign in
-
🚀 Day 48 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Sort Array By Parity Problem Insight: Rearrange the array so that all even numbers come before odd numbers. The order of elements doesn’t matter. Approach: • Used the two-pointer technique (partition logic) • Maintained a pointer j to track the position for even numbers • Traversed the array using i • Whenever an even number is found, swapped it with index j and incremented j • This ensures all even elements move to the front in a single pass Time Complexity: O(n) Space Complexity: O(1) (in-place solution) Key Learnings: • Two-pointer technique is very useful for array partitioning problems • Swapping helps avoid extra space usage • This pattern is similar to problems like moving zeros or segregating positives/negatives Takeaway: Simple logic + optimal approach = clean and efficient solution. Consistency is making these patterns easier to recognize! #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
Day 56 : Crushing Binary Trees on LeetCode 💡 Today’s live practical session in Alpha Plus 7.0 We focused on some of the most challenging Binary Tree questions on LeetCode, breaking down the logic behind them. What I practiced today: ✅ Tree Diameter: understand the logic to calculate the absolute longest path between any two nodes in the entire tree. ✅ Maximum Path Sum: Tackled a famous "Hard" level problem! Figured out how to find the path with the highest possible sum, even if it doesn't pass through the root. ✅ Target Deletion: Wrote the recursive code to systematically find and delete leaf nodes that match a specific target value. #BinaryTree #LeetCode #ProblemSolving #DSA #Java #SoftwareEngineering #100DaysOfCode #ApnaCollege
To view or add a comment, sign in
-
-
Day: 96/365 📌 LeetCode POTD: Minimum Distance to Type a Word Using Two Fingers Hard Key takeaways/Learnings from this problem: 1. This problem is a great example of DP with state as both fingers’ positions, which feels tricky at first but clicks once you model it right. 2. Key learning: instead of deciding both fingers every time, fix one and optimize the movement of the other to reduce complexity. 3. Precomputing distances between characters makes transitions much faster and keeps the code clean. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
-
Day 42/100 – LeetCode Challenge Problem: Top K Frequent Elements Today I worked on the “Top K Frequent Elements” problem, which focuses on identifying the k most frequent elements from an array. I approached this by first using a HashMap to store the frequency of each element. Once the frequencies were calculated, I converted the map into a list of pairs and sorted it based on frequency. From the sorted structure, I extracted the top k elements by selecting from the highest frequency values. This approach keeps the logic straightforward and easy to follow, especially when prioritizing clarity before optimization. While sorting introduces additional overhead, it provides a clean way to rank elements based on frequency. The solution runs in O(n log n) time due to sorting, with O(n) space complexity. This problem reinforced the importance of frequency counting combined with sorting techniques, and how different approaches can be chosen depending on the trade-off between simplicity and efficiency. Forty-two days in. Consistency is now translating into structured thinking. #100DaysOfLeetCode #Java #DSA #Hashing #Sorting #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 76 of #100DaysOfLeetCode with edSlash Today’s problem: Merge K Sorted Lists (LeetCode 23) 🔍 What I learned: How to merge multiple sorted linked lists efficiently Using a Min Heap (Priority Queue) to always pick the smallest element Improving performance over brute force approaches 💡 Key Insight: Instead of merging lists one by one (which can be costly), a priority queue helps maintain the smallest element at the top, reducing overall complexity. ⚡ Approach: Add the head of all lists into a min heap Extract the smallest node and add it to the result Insert the next node of that list into the heap Repeat until heap is empty 📈 Complexity: Time: O(N log K) Space: O(K) Consistency > Motivation 💪 Day 76 and still going strong 🚀 #Day76 #LeetCode #DSA #LinkedList #Heap #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
💻 Day 35 of #LeetCode Journey 🔥 Solved: 19. Remove Nth Node From End of List Today’s problem was all about mastering Linked Lists and understanding the power of the Two Pointer technique. 🔍 Key Idea: Instead of calculating the length, I used a smart approach with fast and slow pointers. Move the fast pointer n steps ahead Then move both pointers together This helps locate the node to remove in a single pass ⚡ Why this approach? Efficient: O(n) time complexity No extra space required Clean and optimal solution 🧠 What I learned: Using a dummy node simplifies edge cases (like removing the head) Two-pointer technique is very powerful in linked list problems 📌 Problem Link: https://lnkd.in/gxXDR-YV #Java #DataStructures #LinkedList #CodingJourney #100DaysOfCode #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 28/100 – LeetCode Challenge Today’s problem: Intersection of Two Arrays (349) 📌 Problem Summary: Given two arrays, find their intersection such that each element in the result is unique. 💡 My Approach: Used HashSet to store elements of the first array Checked elements of the second array using contains() Stored common elements in another set to avoid duplicates Converted the result set into an array 🧠 What I learned today: Efficient use of HashSet for fast lookup (O(1)) How to handle duplicate elements easily Importance of choosing the right data structure Writing clean and optimized code instead of using nested loops 💻 Code Approach (Java): Used sets to ensure uniqueness and optimize performance 🚀 Consistency matters more than perfection 🔑 #Day28 #100DaysOfCode #LeetCode #DSA #Java #CodingJourney #PlacementPreparation
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