🧠 Daily LeetCode Grind — Java Edition Today’s challenge: ✅ Palindrome Number (#9 - Easy) 📌 Goal: Check whether an integer reads the same backward as forward without converting it to a string. 📌 Approach: 🔹 Handle negatives and numbers ending in 0 (except 0 itself). 🔹 Reverse only half of the digits using modulo and division. 🔹 Compare the original and reversed halves for equality. 🧩 Test Cases: Input: 121 → Output: true Input: -121 → Output: false Input: 10 → Output: false 💡 Key Takeaways: 🔹 Strengthened arithmetic-based problem-solving (no string ops). 🔹 Learned efficient O(1) space reversal logic. 🔹 Improved understanding of numeric pattern recognition. 💻 Language: Java 🧠 Complexity: O(log₁₀ n) — reverse digits only once. #LeetCode #Java #CodingPractice #ProblemSolving #DSA #PalindromeNumber #DeveloperLife #AcceptedSolution #CybernautEdTech
How to check if a number is a palindrome in Java
More Relevant Posts
-
🚀 #100DaysOfDSA — Day 26/100 Topic: Arrays as Function Arguments in Java 💻 💡 What I Did Today: Today, I learned how arrays can be passed as arguments to functions in Java — and how changes made inside a function affect the original array. This concept is super important for understanding how references work in Java! ⚙️ 🧠 Logic Used: Defined an update() function that increases every array element by 1. Passed the marks[] array into the function. Observed that updates inside the function reflected in the original array — proving arrays are passed by reference (not by value). 📊 Output: Before update → 66 68 72 68 74 After update → 67 69 73 69 75 ✨ Takeaway: Today’s practice gave me clarity on how data moves between methods in Java. Understanding references helps avoid unexpected behavior and write cleaner, safer code 💡 #100DaysOfCode #Day26 #Java #DSA #Arrays #ProblemSolving #CodingJourney #LearnInPublic #CodeNewbie #DeveloperLife
To view or add a comment, sign in
-
-
🔁 Java DSA Project: Reverse a Linked List#Day5 Built a Java program to demonstrate how to reverse a singly linked list using an iterative approach. This project strengthens understanding of pointers, data structures, and linked list manipulation in Java. ✨ Key Highlights: Custom ListNode class implementation Iterative reversal using prev, curr, and next pointers Simple print function to visualize before & after reversal #Java #DSA #LinkedList #Coding #Algorithms #DataStructures #LearningByCoding
To view or add a comment, sign in
-
-
(Largest Perimeter Triangle — Java 🔺) Hey everyone 👋 Today I explored how to find the largest perimeter triangle from a given array of side lengths using Java. While solving this, I understood how a simple mathematical condition can help in optimizing the entire logic 🔥 Here’s the breakdown 👇 🧠 Concept: To form a valid triangle from 3 sides, the sum of any two sides must be greater than the third one. → a + b > c → a + c > b → b + c > a 💡 Approach 1: Sort the array in descending order and check triplets from the start. If any 3 consecutive sides satisfy the triangle condition, their sum gives the largest perimeter. ⚡ Approach 2 (Optimized): Instead of reversing the array, just sort it in ascending order and iterate from the end — gives the same result but with cleaner logic and less work. 🧩 Time Complexity: O(N log N) 💾 Space Complexity: O(1) This problem helped me understand how sorting order and traversal direction can make an algorithm more elegant and efficient 🚀 📁 Code is available on my GitHub repo: https://lnkd.in/ekjD9s22 #Java #DSA #ProblemSolving #Arrays #CodingJourney #Developers #LearningByDoing #FullStackDeveloper #MCA #GitHub
To view or add a comment, sign in
-
#Day-66) LeetCode 474. Ones and Zeroes – Java DP Solution Just tackled a classic knapsack-style problem using 2D Dynamic Programming in Java. 🧩 Problem: Given a list of binary strings and limits on the number of 0s (m) and 1s (n), find the largest subset such that the total number of 0s and 1s stays within bounds. 🧠 Java Approach: Count 0s and 1s for each string Use a dp[m+1][n+1] table to track the max subset size Iterate backwards to preserve previous states and avoid reuse 💡 Why It Works: This mirrors the 0/1 knapsack pattern — each string is like an item with a cost (0s and 1s) and a value (1). Reverse iteration ensures we don’t double-count. #Java #DynamicProgramming #LeetCode #CodingChallenge #TechPrep #ProblemSolving #PranshuCodes #LinkedInLearning 😊
To view or add a comment, sign in
-
-
Today, I explored one of the most important concepts in Java — the Collection Framework. It plays a major role in handling and manipulating groups of objects efficiently. Here’s what I learned 👇 ✅ Collection Interface – The root interface for working with groups of objects. ✅ List Interface – Allows duplicate elements and maintains insertion order. Examples: ArrayList, LinkedList, Vector ✅ Set Interface – Does not allow duplicate elements. Examples: HashSet, LinkedHashSet, TreeSet ✅ Queue Interface – Used to hold elements in FIFO (First In, First Out) order. Examples: PriorityQueue, LinkedList ✅ Map Interface – Stores key-value pairs. Examples: HashMap, TreeMap, LinkedHashMap 💬 What I found interesting: ArrayList is great for fast access but slower in insert/delete. LinkedList is better for frequent insertions/deletions. HashSet and HashMap provide excellent performance for lookups. 📚 The Java Collection Framework makes data handling more flexible, powerful, and clean — a must-know for every Java developer. #Java #Collections #1000010000 Coders#Programming #Learning #SoftwareDevelopment #CodingJourney
To view or add a comment, sign in
-
-
🔢 Why Does 0123 Print as 83 in Java? 🤔 While working on constructors today, I came across an interesting behavior in Java that reminded me how subtle details in syntax can completely change what your code does! When I wrote this line 👇 Student objectTwo = new Student(0123); I expected it to print 123. But instead, the console output was: 83 So what’s happening here? 💡 In Java, when a number starts with a leading zero (0), it is interpreted as an octal (base 8) number — not a decimal one. Let’s decode it: 0123 (octal) = 1×8² + 2×8¹ + 3×8⁰ = 64 + 16 + 3 = 83 (decimal) Hence, Java prints 83! --- 🧩 Takeaway: ✅ 123 → Decimal (Base 10) ✅ 0123 → Octal (Base 8) ✅ 0x123 → Hexadecimal (Base 16) ✅ 0b1010 → Binary (Base 2) --- 💬 Lesson: Tiny syntax details can make a big difference. Always watch out for leading zeros in numeric literals — they might silently convert your values to something unexpected! --- 🔖 #Java #ProgrammingTips #Developers #CodeLearning #JavaBasics #CodingCommunity #SoftwareEngineering #TechLearning
To view or add a comment, sign in
-
-
🚀Day 96/100 #100DaysOfLeetCode 🧩Problem: Reverse Linked List II✅ 💻Language: Java 💡 Approach: 1️⃣ First, use a dummy node to handle edge cases where reversal starts at the head. 2️⃣ Traverse to the node just before the left position — call it prev. 3️⃣ Reverse the sublist between left and right using standard pointer manipulation. 4️⃣ Reconnect the reversed portion back into the original list. 🔑Key Takeaways: 🔹Dummy nodes simplify linked list edge cases. 🔹In-place reversal reduces memory overhead. 🔹Careful pointer tracking ensures list integrity. ⚙️Performance: ⏱️Runtime: 0 ms(beats 100.00%) 💾Memory: 41.29 MB(beats 70.37%) #100DaysOfLeetCode #Java #LinkedList #CodingJourney #ProblemSolving #DSA #LeetCode #CodingChallenge
To view or add a comment, sign in
-
-
🧠 Java with DSA – Day 38: Linked Logic Today’s focus: building the backbone—singly linked lists in Java. - Created custom Node class with data and next—because every journey starts with a pointer. - Linked nodes manually to form a chain—visualizing memory as a trail of connections. - Printed intermediate nodes to trace flow—because debugging is storytelling. - Realized that linked lists aren’t just data—they’re dynamic, flexible, and foundational. DSA is about more than structures—it’s about understanding how data moves, grows, and adapts. 🚀 All code + notes on GitHub – https://lnkd.in/gGWnjGxk #LinkedListBasics #NodeByNode #CodeWithClarity #ShouryaCodes #100DaysOfCode #DSAFoundation #LinkedInDevJourney #OneQuesADay
To view or add a comment, sign in
-
-
🚀Day 99/100 #100DaysOfLeetCode 🔍Problem: Sum of Two Integers✅ 💻Language: Java 💡Approach: Instead of using the ‘+’ or ‘–’ operators, this problem leverages bit manipulation to perform addition. 🔸Use XOR (^) to calculate the sum without carry. 🔸Use AND (&) followed by a left shift (<< 1) to calculate the carry. 🔸Repeat until no carry remains. 📚Key Takeaways: 🔹Reinforced understanding of bitwise operations. 🔹Learned how addition can be simulated using logical operations. 🔹Improved understanding of low-level arithmetic computation. ⚡Performance: ⏱️Runtime: 0 ms (Beats 100.00%) 💾Memory: 40.88 MB (Beats 10.05%) #100DaysOfLeetCode #Java #BitManipulation #CodingChallenge #ProblemSolving #DSA #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
💡 Java Logical Program Practice — Remove Duplicates & Find Largest Numbers 💻 Today I practiced a simple yet powerful Java logic: ✅ Removed duplicate elements from an array using the Set interface ✅ Found the largest and second largest numbers using loops Concepts used: Array sorting (Arrays.sort()) Set for duplicate removal Loop logic for max & second max values Output: Before remove duplicate: [1, 2, 2, 3, 5, 6, 7, 8, 9, 12, 13, 14, 14, 15] After remove duplicate: [1, 2, 3, 5, 6, 7, 8, 9, 12, 13, 14, 15] Largest number: 15 Second largest number: 14 🧠 This kind of daily logic practice strengthens core Java understanding and logical thinking! #Java #CoreJava #CodingPractice #JavaDeveloper #ProgrammingLogic #ProblemSolving #SetInterface #Array #DailyLearning #LearningInPublic
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