🚀 Day 62/100 of #100DaysOfLeetCode Today’s challenge was “Happy Number” (LeetCode Problem 202). The task was to determine whether a given number is a Happy Number — meaning that by repeatedly replacing the number with the sum of the squares of its digits, the process eventually reaches 1. 💡 Key Takeaways: Strengthened understanding of pointer movement logic. Improved implementation skills using mathematical and logical thinking in Java. #100DaysOfCode #LeetCode #Java #CodingChallenge #ProblemSolving #DataStructures #Algorithms
Solved "Happy Number" challenge on LeetCode in Java
More Relevant Posts
-
🚀 LeetCode Day 3: Reverse Integer Today’s challenge was all about reversing the digits of an integer while handling tricky edge cases — especially negative numbers and integer overflow. 🧠 💡 Problem: Given a signed 32-bit integer, reverse its digits. If the reversed integer overflows, return 0. 🧩 Key Takeaways: Extract digits using modulo and division Manage negative numbers gracefully Check for overflow before building the reversed number 💻 Language: Java ✅ Topic: Math / Integer Manipulation Every day is a new step toward mastering problem-solving and improving coding logic. #LeetCode #100DaysOfCode #Java #CodingChallenge #ProblemSolving #LeetCodeJourney
To view or add a comment, sign in
-
-
Day 89 of #100DaysOfCode Solved Find Numbers with Even Number of Digits in Java 🔢 Approach The goal of this problem was to count how many integers in a given array have an even number of digits. I implemented two methods: findNumbers(int[] nums): This is the main function that iterates through every number in the input array nums. isEvenOrOdd(int n): This helper function takes an integer and determines if its digit count is even or odd. Inside the helper function, I used a while loop to count the digits: I initialized a count to 0. The loop continues as long as $n > 0$. In each iteration, I increment count and then perform integer division by 10 (n = n / 10) to remove the least significant digit. Finally, I return true if the total count of digits is even (count \% 2 == 0). This efficient, digit-by-digit checking approach resulted in a strong performance, beating 98.90% of other submissions. #Java #100DaysOfCode #LeetCode #CodingChallenge #Algorithms #Array #ProblemSolving #Optimization
To view or add a comment, sign in
-
-
Day 19 of #100DaysOfLeetCode 💻 Today’s challenge was about finding two unique numbers in an array where every other number appears twice. At first, I tried using an ArrayList — adding numbers if they weren’t present and removing them if they already existed. The logic worked, but I ran into type conversion issues (Object cannot be converted to int). That’s when I learned the importance of using generics in Java (ArrayList<Integer> instead of raw ArrayList). Small syntax details, but they make all the difference! 🔍 Key takeaways: Always specify the data type in collections. Understand how remove() behaves differently for index vs value. Even a brute-force approach can teach valuable debugging lessons. #Day19 #LeetCode #Java #CodingJourney #100DaysOfCode #Debugging #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 77/100 of #100DaysOfLeetCode Today I solved Binary Search (LeetCode Problem 704), a classic algorithmic challenge and an important concept for efficient searching. The task was to determine the index of a target value in a sorted array using an algorithm with O(log n) time complexity. If the target exists, return its index; otherwise return -1. 💡 Key Takeaway: Binary search is a fundamental algorithm that helps build strong problem-solving intuition and improves understanding of time complexity. #100DaysOfCode #LeetCode #CodingJourney #Java #DSA #BinarySearch #KeepLearning #ProblemSolving
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 74 Count and Say Problem: Given an integer n, return the n-th term of the “Count and Say” sequence a fascinating pattern where each term describes the previous one. Example: Input: n = 4 Output: "1211" My Approach: Used recursion to generate the previous term. Applied run-length encoding logic counted consecutive digits and built the next term using a StringBuilder. Optimized for clean, readable iteration with O(N²) complexity (due to string building). Understanding recursive string construction deepens how we visualize “generation-based” sequences it’s not just about coding, it’s about seeing patterns grow. #100DaysOfCode #Java #LeetCode #ProblemSolving #Recursion #StringManipulation #CodingJourney #TechWithPurpose #takeUforward
To view or add a comment, sign in
-
-
🚀 Day 20 of #100DaysOfLeetCode 💡 Problem: Gray Code Today’s challenge was all about generating the Gray Code sequence, a fascinating binary numbering system where only one bit changes between consecutive numbers. 🧠 Concept: Gray codes are widely used in digital communication and error correction, ensuring minimal transition errors between binary states. 🔍 Key takeaway: Bit manipulation + recursion = elegant solution ✨ 💻 Languages used: Java #LeetCode #100DaysOfCode #ProblemSolving #CodingChallenge #Java #GrayCode #DSA #BitManipulation
To view or add a comment, sign in
-
-
Winter may be coming ❄️, but the code still runs fast ⚔️ Cracked one of the toughest LeetCode Hard problems – Median of Two Sorted Arrays 🔥 Hit 100% runtime efficiency (1 ms) with clean and optimized binary search logic 🧠 This one tested everything — edge cases, math logic, and patience 😅 But as they say… “You win or you debug again.” 🐉 #LeetCode #DSA #CodingJourney #BinarySearch #Java #ProblemSolving #WinterIsComing #GameOfCodes
To view or add a comment, sign in
-
-
🔥 LeetCode Day--- 4 | “Median of Two Sorted Arrays” (Hard, Java) Today’s challenge was one of those that really test your logic, patience, and understanding of binary search. This problem wasn’t about just merging two sorted arrays — it was about thinking smarter 🧠. Instead of brute-forcing through both arrays (O(m+n)), I implemented a binary partition approach to achieve O(log(min(m, n))) efficiency 💡 What I learned today: Always choose the smaller array for binary search — it makes the partition logic simpler. Handle boundaries carefully with Integer.MIN_VALUE and Integer.MAX_VALUE. The goal is to find the perfect partition where: Left half ≤ Right half Elements are balanced across both arrays Once that’s done → median can be easily calculated! ✅ Result: Accepted | Runtime: 0 ms 🚀 Hard problem turned into a logic puzzle that was actually fun to solve! 🧩 Concepts Strengthened: Binary Search Partitioning Logic Edge Case Handling Mathematical Thinking #LeetCode #Day4 #Java #BinarySearch #ProblemSolving #CodingChallenge #DataStructures #Algorithms #CodeEveryday #DeveloperJourney #TechLearning #LeetCodeHard #CodingCommunity
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