Day42/100 #leetcodegrind I successfully implemented a Stack using Queues 💪 It was an amazing problem that helped me deeply understand how data structures work internally. 📚 Key takeaways: Used Queue (FIFO) to mimic Stack (LIFO) behavior Learned how to rotate queue elements after each push Improved my understanding of time complexity and order of operations Every small step builds a strong foundation for mastering DSA 💡 #DSA #Java #CodingJourney #ProblemSolving #Stack #Queue #LeetCode #100DaysOfCode #LearningInPublic
Implemented Stack using Queues in Java for DSA
More Relevant Posts
-
👇 📅 Day 84 of #100DaysOfLeetCode Problem: Find Largest Value in Each Tree Row (LeetCode #515) Approach: The problem requires finding the largest value in each level of a binary tree. This can be efficiently solved using Level Order Traversal (BFS). For each level, store all node values and select the maximum one. Add these maximum values to the result list. Steps: Use a queue to perform level-by-level traversal. For each level, collect node values in a list. Compute the maximum value for that level and add it to the output list. Continue until the queue is empty. Complexity: ⏱️ Time: O(n) — every node is visited once. 💾 Space: O(n) — queue and result storage. 🔗 Problem Link: https://lnkd.in/eQz5GBU8 🔗 Solution Link: https://lnkd.in/eAC_3SwK #LeetCode #100DaysOfCode #BinaryTree #LevelOrderTraversal #BFS #DataStructures #Java #Algorithms #ProblemSolving #DailyCoding #CodingChallenge #BuildInPublic #LearnToCode #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀Day 42/100 - Problem of the day :- Count the Number of Substrings With Dominant Ones. 🎯 Goal:- Solved another interesting LeetCode problem and improved my understanding of prefix-based logic for substring counting. 💡 Core Idea:- The approach uses a prefix tracking array to store the last seen index of '0'. Using this information, we efficiently compute the number of valid substrings ending at each position—without re-checking previous characters. 📌 Key Takeaway:- Efficient solutions come from observing patterns in the input string and leveraging previously computed states. This helps reduce repetitive work and significantly improves performance. 🧠 Time Complexity:- O(n) — We traverse the string once and compute results in a single pass. 💾 Space Complexity:- O(n) — For storing prefix array to track last valid index. #100DaysChallenge #Java #DSA #Day42 #CodingJourney #ProblemSolving #Leetcode
To view or add a comment, sign in
-
-
📌 Day 21/100 – Sort an Array (LeetCode 912) 🔹 Problem: Given an integer array, sort it in ascending order without using built-in sorting functions and ensure the solution runs in O(n log n) time. 🔹 Approach (Merge Sort): Divide the array into two halves recursively Sort each half independently Merge the two sorted halves while maintaining order Uses Divide & Conquer and guarantees stable sorting 🔹 Key Learnings: Merge Sort ensures worst-case O(n log n) time unlike QuickSort Works well for linked lists & large datasets because of stability Uses extra space due to temporary list merging Great example of recursion + two-pointer merging technique #100DaysOfCode #Day21 #LeetCode #Java #DSA #MergeSort #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🎯 Day 82 of #100DaysOfCode – LeetCode 137: Single Number II Today’s challenge was about identifying the unique number in an array where every element appears three times except for one. 🧩 Problem Statement: Given an integer array nums, where every element appears exactly three times except for one, find that single element that appears only once. Example: Input: [2,2,3,2] Output: 3 💭 Approach 1: Using HashMap At first, I solved this using a HashMap to count the frequency of each number. Traverse the array and store each element’s occurrence. Return the element whose count equals 1. 🕒 Time Complexity: O(n) 💾 Space Complexity: O(n) 🚀 Key Takeaway: Sometimes, the best way to optimize is not by adding more data structures, but by understanding how data behaves at the bit level. #100DaysOfCode #Day82 #LeetCode #Java #ProblemSolving #DSA #CodingJourney #BitManipulation #KeepLearning
To view or add a comment, sign in
-
-
🚀 Just implemented a custom Vector<T> class in Java — a dynamic array structure that grows automatically as elements are added. It supports key operations like push_back, pop_back, front, back, clear, and more — all while practicing the concepts of generics, dynamic memory allocation, and data encapsulation. Rebuilding core data structures from scratch is a great way to understand how tools like ArrayList work internally. 💻 #Java #DSA #LearningByDoing #CodingJourney #DataStructures Nohit Singh,Shreyash Khedekar,Anshuman Singh,Arpit Jain
To view or add a comment, sign in
-
💻 Day 53 of #LeetCode100DaysChallenge Solved LeetCode 160: Intersection of Two Linked Lists — a problem that tests linked list traversal, pointer manipulation, and logical thinking. 🧩 Problem: Given the heads of two singly linked lists headA and headB, return the node where the two lists intersect. If they do not intersect, return null. 💡 Approach — Two Pointer Technique: 1️⃣ Initialize two pointers a and b at headA and headB. 2️⃣ Traverse both lists. When a pointer reaches the end of one list, redirect it to the head of the other list. 3️⃣ If the lists intersect, the pointers will meet at the intersection node. 4️⃣ If not, both pointers will eventually become null. ⚙️ Complexity: Time: O(N + M) — each list is traversed at most twice. Space: O(1) — no extra data structure used. ✨ Key Takeaways: ✅ Strengthened understanding of pointer redirection and traversal synchronization. ✅ Learned an elegant approach to detect intersection without measuring lengths. ✅ Reinforced logical thinking in linked list-based problems. #LeetCode #100DaysOfCode #Java #LinkedList #Pointers #TwoPointerTechnique #DSA #CodingJourney #WomenInTech #IntersectionOfLinkedLists
To view or add a comment, sign in
-
-
🌳 Day 73 of #100DaysOfCode 🌳 💡 Problem: Binary Tree Inorder Traversal – LeetCode ✨ Approach: Implemented a recursive inorder traversal to explore the binary tree in Left → Root → Right order. A perfect balance of recursion and logic — the beauty of tree traversal lies in its simplicity 🌿 📊 Complexity Analysis: Time Complexity: O(n)** — visiting each node exactly once Space Complexity: O(n)** — due to recursion stack and list storage ✅ Runtime: 0 ms (🔥 Beats 100%) ✅ Memory: 43.25 MB 🔑 Key Insight: Recursion simplifies complex tree structures into elegant solutions — one node at a time 🌱 #LeetCode #100DaysOfCode #DataStructures #BinaryTree #Recursion #ProblemSolving #DSA #AlgorithmDesign #CodeEveryday #ProgrammerJourney #Java #CodingChallenge
To view or add a comment, sign in
-
-
💻 Day 410 of #500DaysOfCode 🚀 Problem: Minimum One Bit Operations to Make Integers Zero (LeetCode #1611) Difficulty: Hard Today’s challenge was all about bit manipulation — one of those topics that looks simple on the surface but reveals some deep patterns when you dig in. The task: Given an integer n, you have to transform it into 0 using specific bit operations — flipping bits based on certain conditions. At first glance, it seems like a direct simulation problem, but the optimal approach lies in understanding Gray Code transformations! 💡 Key Idea: The number of operations needed to reduce n to 0 follows an inverse Gray code pattern. Using recursion and bitwise manipulation, we can calculate the answer efficiently in O(log n) time. ✨ Concepts Learned: Gray code transformation patterns Recursive bit manipulation How mathematical patterns simplify complex bit problems Each hard problem strengthens logical thinking a bit more 🔥 #Day410 #LeetCode #BitManipulation #Java #CodingChallenge #ProblemSolving #CodeEveryday #500DaysOfCode
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