--------LeetCode Progress Update Solved: Convert a Number to Hexadecimal (405) * Problem Insight: Convert a 32-bit integer into its hexadecimal representation without using built-in conversion methods. * Approach: • Used bit manipulation (num & 15) to extract last 4 bits • Mapped values to hexadecimal characters (0-9, a-f) • Right shift (>>> 4) to process next chunk • Handled negative numbers using 2’s complement logic automatically * Key Learning: Bit manipulation makes low-level operations both efficient and elegant—especially when dealing with number systems. #LeetCode #DSA #Java #BitManipulation #ProblemSolving
Convert 32-bit Integer to Hexadecimal in Java
More Relevant Posts
-
🔥 Day 58 of #100DaysOfCode Solved – Check Balanced String 🔍 What I did: Traversed the string and calculated the sum of digits at even and odd indices separately, then compared both sums to determine if the string is balanced. 💡 Key Learning: Practiced string traversal and indexing Improved understanding of even vs odd index logic Learned how to convert char to integer (c - '0') 🎯 Takeaway: Even simple index-based problems can strengthen your fundamentals and attention to detail. #Day58 #LeetCode #Java #ProblemSolving #CodingJourney #100DaysOfCode #DSA
To view or add a comment, sign in
-
-
🚀 Day 60/100 📌 Problem: String to Integer Given a string, convert it into a 32-bit signed integer while: • Ignoring leading whitespaces • Handling '+' and '-' signs • Reading digits until a non-digit appears • Returning INT_MAX or INT_MIN in case of overflow 💡 What I Learned: • Importance of handling edge cases • How to safely manage overflow • Writing clean and efficient parsing logic ⚡ Result: Runtime 1 ms (Beats 100%) Consistency + Practice = Improvement 📈 #Day60 #Java #DSA #LeetCode #CodingJourney #ProblemSolving #100DaysOfCode #LearnToCode
To view or add a comment, sign in
-
-
📘 DSA Journey — Day 30 Today’s focus: HashMap for frequency counting. Problem solved: • Number of Good Pairs (LeetCode 1512) Concepts used: • HashMap • Frequency counting • Incremental counting technique Key takeaway: The goal is to count pairs (i, j) such that nums[i] == nums[j] and i < j. Instead of checking all pairs (which would take O(n²)), we use a HashMap to track frequencies. As we iterate through the array: • For each number, we check how many times it has already appeared • That count directly contributes to the number of valid pairs • Then we update its frequency in the map This allows counting pairs in a single pass with O(n) time complexity. Continuing to strengthen fundamentals and consistency in problem solving. #DSA #Java #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 47of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Mirror Distance of an Integer Problem Insight: Given a number, the task is to find the absolute difference between the original number and its reversed form. Approach: • Stored the original number in a temporary variable • Reversed the number using digit extraction (modulo and division) • Calculated the absolute difference between the original and reversed number Time Complexity: O(d), where d = number of digits Space Complexity: O(1) Key Learnings: • Digit manipulation using modulo and division is a powerful technique • Always store the original value before modifying the input • Reversing numbers is a fundamental pattern in many DSA problems Takeaway: Breaking the problem into simple steps makes even tricky-looking logic easy to solve. #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
🚀 𝗗𝗮𝘆 - 52/60 Problem: Second Most Repeated String in a Sequence 🔍 Learned: Used a HashMap to count frequencies and identified the second highest frequency by carefully tracking both max and second max values along with their corresponding strings. 😅 Struggles: Initially assumed “second most frequent” meant frequency = 2, which was completely wrong. Also messed up handling updates when max changes—missed tracking the correct string. 🧠 Key Learning: Second maximum is not a fixed number—it depends on the dataset. Whenever tracking max values, always track the associated element too. Order of iteration can break logic if not handled properly. 📦 Concepts Used: #HashMap #Strings #FrequencyCount #LogicBuilding #DSA Most bugs don’t come from syntax—they come from wrong thinking. Fix the logic, and the code follows. 🚀 #Java #CodingJourney #ProblemSolving #DSA
To view or add a comment, sign in
-
-
🚀 Day 6 of #100DaysOfCode | Pattern: Two Pointers Today I tackled a classic Linked List problem: 👉 Remove Nth Node From End of List At first, I thought of a brute force approach: Traverse the list to find length Then remove (length - n) node ❌ Works, but requires 2 passes 💡 Then I learned the optimal approach (Two Pointers): Use fast and slow pointers Move fast n steps ahead Move both together until fast reaches end Delete the node using slow ✅ Only 1 pass ✅ Cleaner and efficient ⚠️ Mistakes I made (important learning): Forgot to use a dummy node → failed for head deletion Got confused between moving n vs n+1 steps Faced null pointer issues in edge cases 🔥 Key Takeaway: Two pointer technique is not just for arrays, it’s super powerful in Linked Lists too 📈 Progress Update: Consistency building day by day Next week: Starting a new pattern Along with revision of Two Pointers #100DaysOfCode #DSA #Java #LinkedList #CodingJourney #ProblemSolving #LearnInPublic #PatternWise
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 87/100 – 𝐋𝐞𝐞𝐭𝐂𝐨𝐝𝐞 𝐂𝐡𝐚𝐥𝐥𝐞𝐧𝐠𝐞 🚀 Problem: 228. 𝐒𝐮𝐦𝐦𝐚𝐫𝐲 𝐑𝐚𝐧𝐠𝐞𝐬 Today I solved a problem where we need to summarize consecutive numbers in a sorted unique array into ranges. 🔑 𝐈𝐝𝐞𝐚: Traverse the array and keep extending the range while consecutive numbers continue. Once the sequence breaks, close the range and store it. 💡 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Start with the first element as start Move forward while nums[i] + 1 == nums[i+1] If range exists → "start->end" Else → single number "start" 𝐊𝐞𝐲 𝐈𝐧𝐬𝐢𝐠𝐡𝐭: Efficient single pass solution (O(n)) by grouping consecutive elements on the fly. #LeetCode #Java #ProblemSolving #DSA #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
Day 56 : Crushing Binary Trees on LeetCode 💡 Today’s live practical session in Alpha Plus 7.0 We focused on some of the most challenging Binary Tree questions on LeetCode, breaking down the logic behind them. What I practiced today: ✅ Tree Diameter: understand the logic to calculate the absolute longest path between any two nodes in the entire tree. ✅ Maximum Path Sum: Tackled a famous "Hard" level problem! Figured out how to find the path with the highest possible sum, even if it doesn't pass through the root. ✅ Target Deletion: Wrote the recursive code to systematically find and delete leaf nodes that match a specific target value. #BinaryTree #LeetCode #ProblemSolving #DSA #Java #SoftwareEngineering #100DaysOfCode #ApnaCollege
To view or add a comment, sign in
-
-
Day: 96/365 📌 LeetCode POTD: Minimum Distance to Type a Word Using Two Fingers Hard Key takeaways/Learnings from this problem: 1. This problem is a great example of DP with state as both fingers’ positions, which feels tricky at first but clicks once you model it right. 2. Key learning: instead of deciding both fingers every time, fix one and optimize the movement of the other to reduce complexity. 3. Precomputing distances between characters makes transitions much faster and keeps the code clean. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
-
Day: 97/365 📌 LeetCode POTD: Minimum Distance to the Target Element Easy Key takeaways/Learnings from this problem: 1. This one shows that sometimes the simplest approach—just scanning the array—is more than enough. 2. Key learning: track the minimum absolute distance on the go instead of storing unnecessary data. 3. Good reminder that not every problem needs fancy algorithms, clarity beats complexity. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
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