Problem 744: Find Smallest Letter Greater Than Target Key Takeaways: Efficiency: Used O(logn) time complexity to find the smallest character strictly greater than the target. The Modulo Trick: Instead of complex if logic, used start % letters.length to handle the wrap-around case when no greater character exists. #LeetCode #Java #BinarySearch
Smallest Letter Greater Than Target in O(logn) Time
More Relevant Posts
-
🌟 Day 9/30 – Group Anagrams Approach: Used a HashMap to group strings. Each word was sorted and used as a key. Strings with the same sorted form were grouped together as anagrams. Complexity: Time: O(n · k log k) Space: O(n) Key Takeaway: Sorting strings and using hashing is a simple and effective way to group anagrams. #DSA #LeetCode #Java #ProblemSolving #30DayChallenge
To view or add a comment, sign in
-
-
This Java nested loop prints a step-based number pattern, helping me understand how small changes in loop conditions create different outputs. Each pattern strengthens: ✔ Logical thinking ✔ Control over nested loops ✔ Problem-solving approach Basics done right lead to long-term growth 💻🔥 👉 Consistency over perfection #Java #NestedLoops #PatternProgramming #ProgrammingLogic #JavaBasics #CodingJourney #LearnByDoing #DeveloperMindset
To view or add a comment, sign in
-
-
LeetCode Practice - 796. Rotate String 💡 Key Idea ✔If goal is a rotation of s, then: ✔Both strings must have the same length ✔goal must be a substring of s + s 🧪 Example Enter string s: abcde Enter goal string: cdeab Output: true Enter string s: abcde Enter goal string: abced Output: false #LeetCode #Java #StringHandling #CodingPractice #ProblemSolving #DSA #DeveloperJourney #TechLearning
To view or add a comment, sign in
-
-
Day 92/100 – #100DaysOfCode 🚀 | #Java #DynamicProgramming #Strings ✅ Problem Solved: Longest Palindromic Subsequence (LeetCode) 🧩 Problem Summary: Given a string, find the length of the longest subsequence that is also a palindrome. (A subsequence does not need to be contiguous.) 💡 Approach Used: ✔ Used Dynamic Programming (2D DP) ✔ Define dp[i][j] as the length of the longest palindromic subsequence in substring s[i…j] Logic: If s[i] == s[j] → dp[i][j] = 2 + dp[i+1][j-1] Else → dp[i][j] = max(dp[i+1][j], dp[i][j-1]) Fill the table bottom-up by increasing substring length ⚙ Time Complexity: O(N²) 📦 Space Complexity: O(N²) ✨ Takeaway: Problems involving subsequences often hint toward DP. Breaking the string into overlapping subproblems makes complex patterns manageable. #Java #LeetCode #DynamicProgramming #Strings #100DaysOfCode #CodingChallenge
To view or add a comment, sign in
-
-
Day 94/100 – #100DaysOfCode 🚀 | #Java #DynamicProgramming #UnboundedKnapsack ✅ Problem Solved: Coin Change II (LeetCode 518) 🧩 Problem Summary: Given an integer amount and an array of coin denominations, return the number of combinations that make up the amount. Each coin can be used unlimited times, and the order of coins does not matter. 💡 Approach Used: ✔ Used Dynamic Programming (1D DP) ✔ This is a classic Unbounded Knapsack problem Steps: Initialize dp[0] = 1 (one way to make amount 0) For each coin: Iterate from coin to amount Update dp[i] += dp[i - coin] This ensures combinations are counted, not permutations ⚙ Time Complexity: O(N × amount) 📦 Space Complexity: O(amount) (where N = number of coins) ✨ Takeaway: The order of loops in DP matters! Iterating coins first avoids counting duplicate permutations and keeps combinations unique. #Java #LeetCode #DynamicProgramming #UnboundedKnapsack #100DaysOfCode #CodingChallenge
To view or add a comment, sign in
-
-
Day 3 of #120DaysOfCode🚀 📌Problem: Replace Elements with Greatest Element on Right Side 📌Language: Java 🔍Approach 1. Maintain a variable maxRight 2. Initially set it to -1 (for last element) 3. Traverse from the end 4. For each element . Save current value . Replace it with maxRight . Update maxRight ⏱️Time & Space Complexity Time Complexity: O(n) Space complexity: O(1) #120DaysOfCode #Day3 #Java #Arrays #DSA #ProblemSolving #Consistenncy #LearningEverday #LearninhPublic #Leetcode
To view or add a comment, sign in
-
-
🚀 LeetCode 1662 – Check If Two String Arrays are Equivalent Combine two string arrays using String.join("", array) and compare with .equals() — solves the problem in just one line! 💡 Returns false if any array is empty. #LeetCode #Java #DSA #ProblemSolving #CodingJourney #LearnToCode #SoftwareEngineer #DailyCoding
To view or add a comment, sign in
-
-
LeetCode 28 – Find the Index of the First Occurrence in a String 🧠 What I learned today: Sometimes the smartest solution is knowing when NOT to overthink 😌 Java’s built-in indexOf() does exactly what the problem asks—clean, efficient, and readable. 💡 Solution Insight: Returns the first index of needle in haystack Automatically returns -1 if not found Time saved = energy saved ⚡ 😄 Fun note: Why write 20 lines of logic when one method call can do the job? indexOf() today, custom logic tomorrow 😉 📈 Consistency > Complexity On to Day 4! 🔥 #100DaysOfCode #DSA #Java #LeetCode #CodingJourney #ProblemSolving #Consistency #LearnByDoing
To view or add a comment, sign in
-
-
💻 #Day33 of #100DaysOfJava — Exploring PriorityQueue in Java ⏫ Today I started exploring the Queue interface in Java, beginning with one of its most popular implementations — PriorityQueue ⚙️ A PriorityQueue is a special type of queue that stores elements based on their natural ordering or according to a custom comparator, instead of just the order of insertion. It’s commonly used in task scheduling, simulations, and algorithms like Dijkstra’s shortest path 🚀 Here’s the clean code I practiced 👇 #Day33 #100DaysOfCode #Java #CoreJava #PriorityQueue #QueueInterface #CollectionsFramework #DataStructures #MinHeap #MaxHeap #JavaDeveloper #LearningByDoing #CodingJourney #CleanCode
To view or add a comment, sign in
-
This Java nested loop prints an increasing number pattern, but more importantly, it strengthened my understanding of how logic grows step by step. 💡 Every pattern teaches something new: ✔ Control of nested loops ✔ Relationship between rows & columns ✔ Building problem-solving mindset Simple code today, stronger developer tomorrow 💻🔥 👉 Consistency > Complexity #Java #NestedLoops #PatternProgramming #LogicBuilding #JavaDeveloper #CodingJourney #LearnByDoing #ProgrammingBasics
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