🚀 Day 60 of #100DaysOfCode Another recursion problem that initially feels tricky, but becomes much clearer once the pattern is understood. 🌱 Topic: Recursion / Divide & Conquer ✅ Problem Solved: LeetCode 779 – K-th Symbol in Grammar 🛠 Approach: Base Case: n == 1 → return 0 Observed that each row is divided into two halves: First half → same as previous row Second half → inverse of previous row Calculated midpoint: 2^(n-2) If k <= mid → go to left half Else → go to right half and invert result #100DaysOfCode #Day60 #DSA #Recursion #DivideAndConquer #LeetCode #Java #Algorithms #ProblemSolving #CodingJourney #Consistency
Recursion in LeetCode 779: K-th Symbol in Grammar
More Relevant Posts
-
#Day75 of my second #100DaysOfCode Today’s problem was more about spotting patterns than writing code. DSA • Solved Single Element in a Sorted Array (LeetCode 540, Medium) – Brute: linear scan checking pairs → O(n) – Optimal: binary search using index pattern → O(log n) • Key idea: elements appear in pairs, and the single element breaks this pattern • Used position-based logic to decide which half to search This one really showed how observing patterns can simplify the approach. #DSA #BinarySearch #LeetCode #Algorithms #Java #100DaysOfCode #WomenWhoCode #BuildInPublic #LearningInPublic
To view or add a comment, sign in
-
-
#Day76 of my second #100DaysOfCode Binary search continues to surprise me with how many variations it has. DSA • Solved Find Peak Element (LeetCode 162) – Brute: check every element → O(n) – Optimal: binary search based on slope comparison → O(log n) • Key idea: if the next element is greater, move right; else move left — a peak is guaranteed • Didn’t need to check all elements, just follow the increasing/decreasing trend Interesting how this doesn’t require a fully sorted array, yet binary search still works. #DSA #BinarySearch #LeetCode #Algorithms #Java #100DaysOfCode #WomenWhoCode #BuildInPublic #LearningInPublic
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 2 Today I worked on a DSA problem based on arrays: Check if an array is sorted and rotated 🔍 Approach: Instead of finding the exact rotation point, I focused on identifying a pattern: In a sorted and rotated array, the order should break at most once. So, I checked how many times an element is greater than the next element while traversing the array in a circular manner. ✔️ If the count of such breaks is 0 or 1 → valid ❌ If it’s more than 1 → not a sorted rotated array 🧠 Key Takeaway: This problem taught me how pattern observation can simplify logic and avoid unnecessary complexity. Sometimes the best solution is not the most obvious one! 📈 Staying consistent and improving step by step 💪 #100DaysOfCode #DSA #DataStructures #Algorithms #Java #CodingJourney #ProblemSolving #LeetCode #Consistency
To view or add a comment, sign in
-
-
🚀 Day 24/100 — #100DaysOfLeetCode Another step forward in strengthening string problem-solving skills 💻🔥 ✅ Problem Solved: 🔹 LeetCode 28 — Find the Index of the First Occurrence in a String 💡 Concepts Used: String Matching Two Pointer / Brute Force Comparison 🧠 Key Learning: The task was to locate the first occurrence of a pattern (needle) inside another string (haystack). I practiced comparing characters sequentially and handling mismatches carefully while traversing the string. ⚡ Insight Gained: Even simple-looking problems help build a strong foundation for advanced string searching algorithms like KMP and Rabin–Karp. Understanding basic string matching logic is essential before moving to optimized pattern-search techniques. Consistency continues 🚀 #100DaysOfLeetCode #LeetCode #DSA #Strings #Algorithms #Java #ProblemSolving #CodingJourney #LearningInPublic #Consistency
To view or add a comment, sign in
-
-
🚀 Day 3/100 – LeetCode Challenge 🔍 Problem: Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be inserted to maintain the sorted order. 💡 Key Concepts Used: • Binary Search • Time Complexity Optimization – O(log n) • Efficient searching in sorted arrays 📚 What I Learned: • How binary search reduces search time significantly compared to linear search • Handling edge cases when the target element is not present • Determining the correct insertion index while maintaining sorted order hashtag #100DaysOfCode #LeetCode #Java #DataStructures #Algorithms #BinarySearch #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
#Day79 of second #100DaysOfCode Binary search on answers is starting to click more now. DSA • Solved Minimum Number of Days to Make m Bouquets (LeetCode 1482) • Given bloom days, find the minimum day to make required bouquets – Brute: check each possible day and count valid bouquets → O(n × max(days)) – Optimal: binary search on days → O(n log max(days)) • Key idea: days form a monotonic search space — if a day works, all later days will also work • Focused on counting consecutive flowers correctly while checking feasibility These problems are really helping me understand how to model conditions for binary search. #DSA #BinarySearch #LeetCode #Algorithms #Java #100DaysOfCode #WomenWhoCode #BuildInPublic #LearningInPublic
To view or add a comment, sign in
-
-
Day 59 of DSA Journey 🚀 Solved Largest Rectangle in Histogram (LeetCode 84) — a problem that looks simple but demands real pattern recognition. 💡 Key Takeaways: • Monotonic Stack is 🔑 • Focus on nearest smaller elements • Think in terms of boundaries, not brute force ⚡ Complexity: O(n) time | O(n) space 📊 Result: 71 ms | Beats 38.67% Learning > Performance. Improving daily. 💪 #DSA #LeetCode #Java #100DaysOfCode #Consistency #ProblemSolving
To view or add a comment, sign in
-
-
Day 19 of #100DaysOfCode Solved “Base 7” problem today — a simple yet insightful exercise on number systems. 💡 Approach: Convert the integer into base 7 by repeatedly dividing by 7 and storing remainders. Handle negative numbers separately and reverse the result at the end. ⚡ Key Learning: Even easy problems strengthen fundamentals like loops, math logic, and edge case handling. Consistency > Complexity. #LeetCode #DSA #CodingJourney #Java #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 72 — LeetCode Practice 🚀 Today’s problem: Sorting the Sentence 💡 What I learned today: • Practiced string manipulation and splitting techniques • Understood how to extract numbers from characters using ASCII logic • Learned to map words to correct positions using indexing • Improved attention to detail while handling edge cases 🧠 Key idea: Each word has a number at the end → use it to place the word in the correct position → then remove the number and rebuild the sentence. ✨ Consistency is slowly turning confusion into clarity. #Day72 #LeetCode #Java #ProblemSolving #DSA #CodingJourney #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