Just cracked LeetCode #9 – Palindrome Number. Sounds simple, but the follow-up challenge of solving it without converting to a string makes you really think about the math behind it. 🚀 The approach was straightforward — reverse the number mathematically (no string conversion!) and compare it with the original. Negative numbers and trailing zeros are the edge cases that catch you off guard if you're not careful. 🧑💻 Beats 79.66% in runtime and 95.20% in memory. Not perfect, but I'll take it. One problem at a time. That's the game. 💪 #LeetCode #Java #DSA #CodingJourney #ProblemSolving
Sanyam Kumar’s Post
More Relevant Posts
-
Solved the Flatten a Multilevel Doubly Linked List problem using iterative pointer manipulation. The idea is to traverse the list, and whenever a node has a child, we attach the child list in between the current node and its next node. Then we find the tail of the child list and connect it back to the original next node. This way, we flatten the list in-place without using extra space. Time Complexity: O(n) Space Complexity: O(1) #Java #DSA #LinkedList #LeetCode #Coding
To view or add a comment, sign in
-
-
Day 61 of 100 Days of LeetCode 🚀 Solved First Unique Character in a String (LeetCode 387) today. 🔍 Key Learnings: Used frequency array to count character occurrences efficiently Importance of two-pass approach: Count frequencies Identify first unique character Reinforced concept of optimizing from brute force (O(n²)) to linear time (O(n)) ⚡ Complexity: Time: O(n) Space: O(1) (fixed 26 characters) 💡 Small problem, but a good reminder that clean logic and simplicity beat overcomplication. #Day61 #100DaysOfCode #LeetCode #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 91 — LeetCode Practice 🚀 Today’s focus was on string processing and distance calculation. ✅ Problem Solved: 🔹 Shortest Distance to a Character 💡 Key Learnings from Today: • Understood how to calculate minimum distance between characters • Strengthened nested loop logic and condition checking • Learned how to track and update minimum values efficiently • Improved problem-solving using brute-force approach • Practiced working with strings and indices 📌 Approach Used: For each character in the string, I checked all positions of the target character and calculated the minimum distance. 🎯 Next Step: Will optimize this solution using two-pass approach (left-to-right & right-to-left) for better efficiency. Consistency is building step by step 💪 #Day91 #LeetCode #CodingJourney #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 7 of #LeetCode Challenge 🔍 Problem: Sqrt(x) 💡 Approach: Used the built-in Math.sqrt() function to compute the square root and then typecasted it to an integer to get the floor value. 🧠 Key Concept: Understanding how to convert a floating-point result into an integer using typecasting. 🔥 #Day7 #LeetCode #Java #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 56/100 Today’s problem: String Compression (In-place) 💡 Key Learnings: - Learned how to use Two Pointers (Read & Write) efficiently - Understood in-place modification without extra space - Handled edge cases like counts greater than 9 (e.g., 12 → '1','2') - Improved thinking around grouping consecutive characters 🧠 Approach: Used a read pointer to traverse the array and a write pointer to update the compressed result directly in the same array. ⚡ Time Complexity: O(n) 📦 Space Complexity: O(1) Consistency is the real game 💯 #Day56 #Java #DSA #CodingJourney #LeetCode #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 74 — LeetCode Practice 🚀 Today’s problem: Split a String in Balanced Strings 💡 What I learned today: • Understood the concept of balanced strings (equal number of 'L' and 'R') • Learned how to use a counter approach instead of extra space • Practiced greedy logic to split the string at the right moment • Improved my ability to track conditions while iterating through strings 🧠 Key Idea: Maintain a counter → Increment for 'L' Decrement for 'R' Whenever the counter becomes 0, we found a balanced substring ✅ 🔥 Takeaway: Simple logic + careful observation = efficient solution Consistency is the real game changer 💯 #Day74 #LeetCode #DSA #Java #CodingJourney #Consistency #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 5 of #LeetCode Challenge 🔍 Problem: Minimum Distance Between Three Equal Elements I 💡 Approach: Used a brute-force approach with three nested loops to check all possible triplets (i, j, k). Checked if nums[i] == nums[j] == nums[k] Calculated distance using: |i - j| + |j - k| + |k - i| Tracked the minimum distance using Math.min() 🧠 Key Concept: Understanding triplet traversal and applying absolute distance formula. 🔥 #Day5 #LeetCode #Java #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 8 / 150 – LeetCode Challenge 📌 Problem: Plus One Today’s problem was simple but teaches an important concept — handling carry in arrays. 💡 Given a number represented as an array of digits, we need to add +1 and return the result. 🔑 Key Insight: - Start from the last digit - If digit < 9 → just add 1 and return - If digit == 9 → make it 0 and carry forward - If all digits are 9 → create a new array with leading ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(1) (except edge case) Consistency > Motivation. 8 days done, 142 to go 💪 #LeetCode #CodingChallenge #DataStructures #Java #Consistency #100DaysOfCode #CodingThinker
To view or add a comment, sign in
-
-
Day 22/100: Longest Common Prefix 📏 Today's challenge was about finding the common starting thread in an array of strings. The Logic: Vertical Scanning Instead of comparing whole words, I looked at them character by character across the entire list. If "flower", "flow", and "flight" all have 'f' and 'l' at the start, that's our prefix. As soon as a mismatch happens, we cut the string and return the result. Complexity: O(S) where S is the sum of all characters in all strings. #100DaysOfCode #Java #DSA #Strings #CodingJourney #Day22 #LearnInPublic
To view or add a comment, sign in
-
-
🚀 Day 25/100 Days of Code Challenge 🔥 Problem: Rotate String(Leetcode 796) We are given two strings s and goal. 👉 We need to check if we can rotate string s (move first character to last again and again) to make it equal to goal. 📌 Example: abcde → bcdea → cdeab → deabc → eabcd ⚙️ Approach Check if lengths of both strings are equal Concatenate string with itself → s + s Check if goal exists inside the new string ⏱️ Complexity Time Complexity: O(n) Space Complexity: O(n) 📚 What I Learned ✔️ Simple tricks can save time ✔️ Avoid unnecessary loops ✔️ Think smart, not hard 💪 Day by day improving 🚀 #100DaysOfCode #Coding #Java #DSA #LearningJourney
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