🚀 Problem 3: Palindrome Number 💡 Leetcode problem no:9 Today I explored another classic coding challenge — checking if a number is a palindrome 🔁 ✨ Challenge: Determine whether an integer x reads the same forward and backward. If x is a palindrome, return true, otherwise return false. 💻 My Java Approach: 🔹 Stored the original number for comparison 🔹 Used modulus (%) and division (/) to reverse digits 🔹 Compared the reversed number with the original one 🔹 Added a quick check to handle negative numbers efficiently 💙 Tip: Palindrome logic is simple yet powerful — it’s all about understanding digit manipulation and integer handling in Java. #Java #Coding #LeetCode #ProblemSolving #CodingJourney #JavaDeveloper #LeetcodeCoding
Brahmaiah Talluri’s Post
More Relevant Posts
-
Today’s problem: Palindrome Number 🔢 Problem: Check whether a given integer is a palindrome (reads the same forward and backward). Examples: 121 → true ✅ -121 → false ❌ 10 → false ❌ Approach I used: ✅ Negative numbers are not palindromes. ✅ Convert the integer to a string. ✅ Use two-pointer technique (left and right) to compare characters from both ends. ✅ If all pairs match → it’s a palindrome. A clean and efficient way to solve this classic problem. ⚡
To view or add a comment, sign in
-
-
Learn in Public: Make the Smallest Possible Palindrome Problem We are given a string. Our goal is to turn it into a palindrome using the fewest character changes. If several palindromes use the same number of changes, we choose the one that is smallest in dictionary order. Example Input: "egcfe" Output: "efcfe" Only one change was needed: g → f. Approach : Two-Pointer && Greedy Method Why I used two pointers Approach A palindrome is symmetric. So we compare the left and right characters and move inward step by step. Why use a char array Java strings cannot be changed directly. Using a char[] makes updates simple. Why choose the smaller character If the characters do not match, at least one must be changed. Setting both to the smaller one: Keeps changes minimal Produces the smallest possible palindrome Does not affect other pairs This makes the greedy method correct. Time Complexity: O(n) Space Complexity: O(n) Code Link : https://ideone.com/X9OL7m What I Learned Two pointers make symmetric problems easy. Choosing the smaller character gives the best smallest palindrome. #LearnInPublic #Java #CodingPractice #Algorithms #TwoPointers #Greedy #Programming #DSA #ProblemSolving #Palindrome #JavaDeveloper #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
NeetCode 21 | LeetCode #76 | Minimum Window Substring Used two pointers and HashMaps to maintain a dynamic window tracking character frequencies. Achieved an optimized O(n) solution with careful window expansion and contraction logic. #NeetCode #LeetCode #Algorithms #Java #DataStructures #Optimization #Coding
To view or add a comment, sign in
-
🚀 Day 31 of #100DaysOfCode 💡 Problem: LeetCode 680 — Valid Palindrome II 🧠 Concepts: Two Pointers, String Manipulation Sometimes, one small allowance can make all the difference — 👉 Here, we’re allowed to delete at most one character to check if the string can still be a palindrome. So the approach was simple yet elegant: 1️⃣ Use two pointers from both ends. 2️⃣ If characters mismatch, try skipping either the left or the right one — check both possibilities. 3️⃣ If any path forms a palindrome, return true ✅ This problem beautifully shows how a small constraint tweak (like “delete at most one char”) transforms logic from basic palindrome check → into a clever conditional validation. 🔥 Lesson: Sometimes in life (and code), you don’t have to be perfect — just one small correction can still make things right. #LeetCode #Java #TwoPointers #ProblemSolving #DSA #CodingJourney #100DaysOfCode #LearnEveryday
To view or add a comment, sign in
-
-
✅ Day 20 — LeetCode Challenge 📌 Problem: 409 — Longest Palindrome Today, I worked on determining the maximum length of a palindrome that can be formed using characters from a given string. Since palindromes require characters in pairs, the goal is to count how many such pairs exist, and optionally place one odd character at the center. 🔹 Approach Use a HashSet to track characters. When a character repeats → remove it from the set → increase pair count. At the end: If set is not empty → one extra odd character → add +1 to result. ✅ Time Complexity: O(n) ✅ Space Complexity: O(1) 💡 Key Takeaway: A simple data structure like HashSet can smartly identify matching character pairs, helping us build the longest palindrome efficiently. #Day20 #LeetCode #DSA #CodingJourney #Java #ProblemSolving #Palindrome #TechLearning
To view or add a comment, sign in
-
-
🚀 Day 140 of #150DaysOfCode on LeetCode Solved: 1526. Minimum Number of Increments on Subarrays to Form a Target Array Language: Java The task was to determine the minimum number of subarray increment operations needed to build the target array from all zeros. 🔹 Intuition: Every time the current element is greater than the previous one, it means we need that many new operations to reach the next level. Decreases don’t add extra work since earlier increments already cover them. 🔹 Approach: Start with the first element’s value as the initial count. For each subsequent element, if it’s larger than the previous one, add the difference. The sum of all such differences gives the minimum number of operations required. 🔹 Complexity: Time: O(n) Space: O(1) #LeetCode #150DaysOfCode #Java #CodingChallenge #ProblemSolving #Greedy #Arrays #DSA #TechLearning #Programmer #WomenInTech #CodeJourney #DynamicProgramming
To view or add a comment, sign in
-
-
Day 43 of #50DaysOfLeetCodeChallenge Problem: Valid Parentheses Approach: Used a stack to keep track of opening brackets. For each closing bracket, checked if it matches the top of the stack. Returned false if there was a mismatch or stack was empty. This ensures all brackets are properly nested and closed. Key Takeaways: Stacks are perfect for problems involving nested structures. Simple traversal with O(n) time complexity and O(n) space. Feeling more confident handling pointers and references in Java! Performance: Using a stack this way really helped me understand how to manage nested elements efficiently. #LeetCode #Java #DSA #CodingChallenge #ProblemSolving #Stack #Programming
To view or add a comment, sign in
-
-
✅Day 74 of #100DaysOfLeetCode 1.📌Problem: Reverse Vowels of a String 2.🟩 Difficulty: Easy 3.📍Topic: Two Pointers 4.🎯 Goal: Given a string, reverse only the vowels in the string and return the modified string. Vowels include 'a', 'e', 'i', 'o', 'u' in both lower and upper cases. 5.🧠key idea: Approach 1: Use two pointers, one starting from the beginning and one from the end. Move towards each other, swap the vowels found at each pointer, and continue until all vowels are reversed. #LeetCode #CodingChallenge #100DaysOfCode #Algorithms #TechCareers #CodeNewbie #WomenWhoCode #Java #Programming #DailyCoding #Developer #InterviewPrep #TwoPointers #DataStructures #LearnToCode #ProblemSolving
To view or add a comment, sign in
-
-
NeetCode 20 | LeetCode #567 | Permutation in String Applied sliding window with character frequency tracking to efficiently check for permutations in a string. A great exercise in combining logic, hash maps, and window optimization. #NeetCode #LeetCode #Java #DSA #Algorithms #SlidingWindow #ProblemSolving #CodingJourney
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