Day 31/100 – LeetCode Challenge 🚀 Problem: Roman to Integer Approach: Mapped Roman symbols to their integer values Traversed the string once If the current value was less than the next value, subtracted it Otherwise, added it to the total Time Complexity: O(n) Space Complexity: O(1) Key takeaway: When dealing with special formatting rules (like subtraction cases), comparing the current and next element often simplifies the logic. #LeetCode #100DaysOfCode #DSA #Java #Strings #ProblemSolving
Roman to Integer LeetCode Challenge
More Relevant Posts
-
LeetCode Problem || Check if Binary String Has at Most One Segment of Ones(1784)🚀 we need to check: The string should have only one continuous block of '1's. After a '0' appears, '1' should never appear again. ✨ Insight: Instead of manually counting segments using loops, we can simply check if "01" exists in the string. 📌 Time Complexity: O(n) Practicing problems like these helps improve pattern recognition and problem-solving efficiency. #LeetCode #DSA #Java #CodingPractice #ProblemSolving
To view or add a comment, sign in
-
-
Solved "Container With Most Water" on LeetCode today using the Two-Pointer Technique. 🚀 The key insight is that the area formed by two lines depends on the shorter height and the distance between them. Starting with pointers at both ends of the array, we compute the area and move the pointer at the smaller height inward to potentially find a taller boundary and maximize the area. This approach efficiently reduces the problem from O(n²) brute force to O(n) time with O(1) space. Problems like this are a great reminder that the right observation can drastically optimize a solution. 💡 #LeetCode #DSA #TwoPointers #Java #ProblemSolving
To view or add a comment, sign in
-
-
Day 40 of 100 Days of Code 🚀 Solved Maximum Consecutive Ones today. 🔹 Problem: Find the longest streak of 1’s in a binary array. 🔹 Approach: Single pass with running counter. Key idea: - Increment count when we see 1 - Reset when we see 0 - Track maximum during traversal ⏱ Time Complexity: O(n) 📦 Space Complexity: O(1) Small problems strengthen logical thinking and loop control. #LeetCode #DSA #Java #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 42 of #100DaysOfCode 🌱 Topic: Linked List / Two Pointers ✅ Problem Solved: LeetCode 82 – Remove Duplicates from Sorted List II 🛠 Approach: Used a dummy node to simplify handling edge cases where the head might be removed. When two consecutive nodes had the same value, stored that value. Skipped all nodes with that duplicate value using a loop. Linked the previous node to the next distinct node. Continued traversal until reaching the end. This ensures that only unique elements remain in the sorted list. #100DaysOfCode #Day42 #DSA #LinkedList #TwoPointers #LeetCode #Java #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 19 of #100DaysOfCode Solved 2. Add Two Numbers on LeetCode ➕🔗 (in-place linked list approach) 🧠 Key insight: Instead of creating a new list, we can reuse the longer linked list and perform addition in place, handling carry carefully across nodes. ⚙️ Approach: 🔹Calculate the size of both linked lists 🔹Use the longer list as the result list 🔹Traverse both lists, adding values with carry 🔹Continue processing remaining nodes of the longer list 🔹Append a new node if a carry remains at the end ⏱️ Time Complexity: O(max(n, m)) 📦 Space Complexity: O(1) (no extra list created) #100DaysOfCode #LeetCode #DSA #LinkedList #Java #ProblemSolving #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
-
#Day39 of #365DaysOfCode Solved Set Matrix Zeroes on LeetCode. Implemented an in-place matrix approach using the first row and column as markers to track zero positions. ✨ Lesson: Smart space optimization and careful traversal help solve matrix problems efficiently. #CodingJourney #DSA #Java #LeetCode #Consistency
To view or add a comment, sign in
-
-
Day 36/100 – LeetCode Challenge 🚀 Problem: 3Sum Closest Approach: Sorted the array Fixed one element and applied the two-pointer technique Tracked the closest sum by comparing absolute differences Returned immediately if an exact match was found Time Complexity: O(n²) Space Complexity: O(1) Key takeaway: Many optimization problems are variations of classic patterns. Understanding 3Sum deeply makes solving 3Sum Closest straightforward. #LeetCode #100DaysOfCode #DSA #Java #TwoPointers #ProblemSolving #InterviewPrep
To view or add a comment, sign in
-
-
🚀 Day 98 of #100DaysOfCode Solved LeetCode #1356 – Sort Integers by The Number of 1 Bits ✅ A clean bit manipulation + sorting problem that rewards thinking beyond plain comparisons. Key Takeaways: -> Using Integer.bitCount() to count set bits efficiently -> Encoding sort priority directly into values for simplicity -> Leveraging built-in sorting for clean and fast solutions -> Small tricks can lead to elegant code ✨ Language: Java -> Runtime: 6 ms (Beats 93.70%) ⚡ -> Memory: 47.42 MB Almost there. Staying consistent till the end 💻🔥 #LeetCode #Java #BitManipulation #Sorting #ProblemSolving #DSA #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 23/100 – LeetCode Challenge Today’s problem: Partitioning Into Minimum Number of Deci-Binary Numbers 🔹 Key Insight: The minimum number of deci-binary numbers required is equal to the maximum digit present in the string. 🔹 Approach: Traverse through each character in the string Convert it to integer (ch - '0') Track the maximum digit Return the maximum value 🔹 Time Complexity: O(n) 🔹 Space Complexity: O(1) ✨ Simple logic, but powerful observation! Instead of constructing numbers, we just analyze the digits. Consistency > Motivation 💪 #Day23 #100DaysOfCode #LeetCode #Java #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 20/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 350. Intersection of Two Arrays II Used sorting + two-pointer technique to efficiently find common elements appearing in both arrays while maintaining correct frequency. ⏱️ Time Complexity: O(n log n + m log m) 📦 Space Complexity: O(min(n, m)) (for storing the intersection) Strengthening understanding of array traversal and two-pointer pattern through consistent practice. 💪 Consistency keeps the progress moving 🚀 #DSA #LeetCode #Java #CodingJourney #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