🚀Day 20 of #120DaysOfCode 📌 Problem: Reverse Integer(7) 📌 Language: Java Algorithm: 1. Initialize rev = 0 2. While x != 0 . Extract digit . Check overflow . Update rev 3. Return rev ⏱️ Time and Space Complexity Time Complexity: O(logn) Space complexity: O(1) 🔥One problem closer to mastery #120DaysOfCode #Day20 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
Reverse Integer in Java with O(logn) Time Complexity
More Relevant Posts
-
DSA journey 🚀 📌 LeetCode #268 – Missing Number 💻 Language: Java 🔹 Approach: Use the sum of first n natural numbers formula Calculate the expected sum: n * (n + 1) / 2 Find the actual sum of array elements The difference gives the missing number 🔹 Formula Used: Missing Number = Expected Sum − Actual Sum ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(1) Simple math, clean logic ✨ Consistency over perfection 💯 #DSA #Java #LeetCode #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
📝 Day 19/30 – LeetCode #33 (Search in Rotated Sorted Array) | Java This problem combines binary search with array rotation, making it more about logic than syntax. The main challenge was identifying which half of the array is sorted at every step and deciding whether the target lies within that range. By comparing boundary values and narrowing the search space accordingly, the problem can be solved efficiently in O(log n) time. This reinforced how adaptable binary search becomes when combined with careful condition checks. Another reminder that mastering patterns is far more important than memorizing solutions. #LeetCode #Java #DSA #BinarySearch #Arrays #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
DSA journey 🚀 📌 LeetCode #1 – Two Sum 💻 Language: Java 🔹 Approach: Use two nested loops to check all possible pairs Compare the sum of each pair with the target Return indices once the matching pair is found ⏱ Time Complexity: O(n²) 🧩 Space Complexity: O(1) Consistency over perfection 💯 #DSA #Java #LeetCode #ProblemSolving #LearningInPublic #DSAWithedSlash
To view or add a comment, sign in
-
-
DSA journey 🚀 📌 LeetCode #167 – Two Sum II (Input Array Is Sorted) 💻 Language: Java 🔹 Approach (Two Pointer Technique): Initialize two pointers at the start and end of the sorted array Calculate the sum of both pointers If the sum equals the target → return 1-based indices If the sum is smaller than the target → move the start pointer forward If the sum is greater than the target → move the end pointer backward Efficient use of the sorted property 💡 ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(1) Step-by-step clarity before optimization ✨ Consistency over perfection 💯 #DSA #Java #LeetCode #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
𝐖𝐞𝐞𝐤 2 | 𝐃𝐚𝐲 5/7 — 𝐃𝐒𝐀 𝐂𝐡𝐚𝐥𝐥𝐞𝐧𝐠𝐞 Today, I practiced generating all possible 𝐩𝐞𝐫𝐦𝐮𝐭𝐚𝐭𝐢𝐨𝐧𝐬 of an array of distinct integers using Java. 𝐊𝐞𝐲 𝐇𝐢𝐠𝐡𝐥𝐢𝐠𝐡𝐭𝐬: • Implemented backtracking to explore all possible sequences • Used a temporary list to build permutations step by step • Applied recursive calls and backtracking by adding/removing elements • Reinforced concepts of recursion, lists, and algorithmic problem solving This challenge helped me strengthen my problem-solving skills and understanding of recursive algorithms, which are widely used in DSA problems and real-world applications. #Day5Of7DaysOfCode #DSA #Java #Backtracking #ProblemSolving #Algorithm #CodingChallenge #Recursion
To view or add a comment, sign in
-
-
DSA journey 🚀 📌 LeetCode #509 – Fibonacci Number 💻 Language: Java 🔹 Approach: - Handle base cases (n == 0 and n == 1) - Use an iterative approach instead of recursion - Build the Fibonacci sequence using variables ⏱ Time Complexity: O(n) 🧩 Space Complexity: O(1) Consistency over perfection 💯 #DSA #Java #LeetCode #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
Day 25 of #100DaysOfLeetCode 💻✅ Solved #167. Two Sum II – Input Array Is Sorted on LeetCode using Java. Approach: • Used Two Pointer technique since the array is already sorted • Initialized one pointer at the beginning and one at the end • Calculated the sum of both elements • If sum < target, moved left pointer forward • If sum > target, moved right pointer backward • Returned 1-based indices as required in the problem Performance: ✓ Runtime: 1 ms (Efficient with O(n) time complexity) ✓ Memory: Constant extra space (O(1)) Key Learning: ✓ Understood when to apply Two Pointer technique instead of HashMap ✓ Improved ability to optimize space complexity ✓ Strengthened pattern recognition for sorted array problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #TwoPointers #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Week 2 of Java DSA – Arrays Deep Dive This week, I went deeper into Arrays using Java and focused on improving problem-solving skills through medium-level DSA problems. 🔹 What I worked on: • Arrays in depth (indexing, patterns, edge cases) • Optimizing solutions using better logic • Solving medium-level array problems • Improving time complexity awareness while coding 🔹 Key learnings: • Small optimizations can make a big difference • Handling edge cases is as important as core logic • Writing efficient array-based solutions requires clarity, not speed Continuing the journey with more challenging problems ahead 🚀 #Java #DSA #Arrays #ProblemSolving #LearningInPublic #Consistency #LeetCode
To view or add a comment, sign in
-
-
DSA journey 🚀 📌 LeetCode #231 – Power of Two 💻 Language: Java 🔹 Approach: - Handle base cases (n < 1 and n == 1) - Keep dividing the number by 2 while it is even - If the final value becomes 1, it is a power of two ⏱ Time Complexity: O(log n) 🧩 Space Complexity: O(1) Consistency over perfection 💯 #DSA #Java #LeetCode #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
𝐖𝐞𝐞𝐤 𝟐 | 𝐃𝐚𝐲-𝟏/𝟕 𝐂𝐡𝐚𝐥𝐥𝐞𝐧𝐠𝐞 𝐏𝐫𝐨𝐛𝐥𝐞𝐦: Find Unique Subsets 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: Medium Today, I solved the classic “Subsets” problem (also known as Power Set) using recursion and backtracking in Java! Given an array of unique integers, the goal was to generate all possible subsets. ✨ Highlights of my solution: Clean recursive backtracking approach Explicit base case for recursion termination Explored both include and exclude choices for each element Passed all test cases with a fast runtime (1 ms) This problem is an excellent exercise to strengthen understanding of recursion, backtracking, and subset generation. #Day1Of #7DaysOfCode #LeetCodeChallenge #Java #Recursion #Backtracking #CodingJourney #ProblemSolving
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