100 Days of Coding Challenge – Day 16 📌 Problem: Roman to Integer 💻 Language: Java 🧠 Concept Used: HashMap + Conditional Traversal 🔍 Platform: LeetCode Today’s challenge was converting a Roman numeral into its integer representation. Approach: ✔ Stored Roman symbols and values in a HashMap ✔ Traversed the string from left to right ✔ If the current value is smaller than the next → subtract ✔ Otherwise → add Time Complexity: O(n) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/g2YTaPrG 🔗 Code: https://lnkd.in/g7e_Y7V7 #100DaysOfCode #Day16 #Java #DSA #LeetCode #Strings #ProblemSolving #CodingJourney
Converting Roman Numerals to Integers in Java
More Relevant Posts
-
100 Days of Coding Challenge – Day 30 📌 Problem: Find the Index of the First Occurrence in a String 💻 Language: Java 🧠 Concept Used: String Matching (Brute Force) 🔍 Platform: LeetCode Today’s challenge was to find the first occurrence of a substring (needle) in a given string (haystack). If not found, return -1. Example: Input: "sadbutsad", "sad" Output: 0 Approach: ✔ Traverse the string from index 0 to n - m ✔ Extract substring of length m at each position ✔ Compare it with the target string ✔ Return index immediately when match is found ✔ If no match → return -1 Time Complexity: O(n × m) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/g2ktYFFS 🔗 Code: https://lnkd.in/gynFixSQ #100DaysOfCode #Day30 #Java #DSA #LeetCode #Strings #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 19 📌 Problem: Merge Sorted Array 💻 Language: Java 🧠 Concept Used: Array Manipulation + Sorting 🔍 Platform: LeetCode Today’s challenge was to merge two sorted arrays into a single sorted array. The result must be stored inside the first array (nums1). Approach: ✔ Copy elements from both arrays into a temporary array ✔ Place the combined elements back into nums1 ✔ Sort the final array to maintain non-decreasing order Time Complexity: O((m+n) log (m+n)) Space Complexity: O(m+n) 🔗 Problem Link: https://lnkd.in/gyFfUaiE 🔗 Code: https://lnkd.in/gA-MrnqG #100DaysOfCode #Day19 #Java #DSA #LeetCode #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 55 of #100DaysOfLeetCode 💻✅ Solved #434. Number of Segments in a String problem in Java. Approach: • Initialized a counter to track number of words (segments) • Traversed the string character by character • Checked for non-space characters • If the current character is not a space and either it is the first character or the previous character is a space, incremented the count • This ensures counting only the starting of each word Performance: ✓ Runtime: 0 ms (Beats 100% submissions) 🚀 ✓ Memory: 41.83 MB (Beats 99.81% submissions) Key Learning: ✓ Practiced string traversal without using extra space ✓ Learned how to identify word boundaries efficiently ✓ Improved logic building for handling spaces and edge cases Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 2 of my #365DaysCodingChallenge | CodeOjas Journey Today, I solved 3 interesting array-based problems using Java: 🔹 Unique Subarray Sum Pairs – Found pairs of subarrays with equal sums using hashing techniques. 🔹 Array Rotation – Rotated array efficiently using optimized reversal approach. 🔹 Shifted Array – Implemented element shifting with proper handling of wrap-around using modular arithmetic. 💡 Approach: Focused on breaking problems into smaller parts, using concepts like subarrays, indexing, and optimization techniques. ⚡ Complexity: Most solutions were optimized to O(n) time with minimal space. 📌 Takeaway: Strong understanding of array manipulation and problem breakdown is key to solving DSA problems efficiently. Building consistency and improving every day 💪🔥 📂 Code: [Your GitHub Link] #DSA #Java #CodeOjas #365DaysOfCode #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
Day 61 of #100DaysOfLeetCode 💻✅ Solved #541. Reverse String II problem in Java. Approach: • Converted the string into a character array • Traversed the array in steps of 2k • For every segment, reversed the first k characters • Used two-pointer technique to perform in-place reversal • Math.min() to handle cases where remaining characters are less than k Performance: ✓ Runtime: 2 ms (Beats 16.04% submissions) ✓ Memory: 44.80 MB (Beats 73.53% submissions) Key Learning: ✓ Practiced handling strings with fixed pattern intervals ✓ Improved control over indexing and boundaries ✓ Strengthened in-place modification techniques Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #TwoPointers #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 23 📌 Problem: Longest Consecutive Sequence 💻 Language: Java 🧠 Concept Used: Sorting + Sequence Counting 🔍 Platform: LeetCode Today’s challenge was to find the length of the longest sequence of consecutive numbers in an unsorted array. The numbers do not need to be adjacent in the original array, but they must form a continuous sequence like 1,2,3,4. Example: Input: [100, 4, 200, 1, 3, 2] Output: 4 → Longest sequence: [1,2,3,4] Approach: ✔ First sort the array ✔ Traverse the array and check if the next number is consecutive ✔ Skip duplicates ✔ Track the longest streak using a counter Time Complexity: O(n log n) (due to sorting) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/gguN6KnH 🔗 Code: https://lnkd.in/gyVFpsbg #100DaysOfCode #Day23 #Java #DSA #LeetCode #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 26 📌 Problem: Remove Duplicates from Sorted Array II 💻 Language: Java 🧠 Concept Used: Two Pointer Technique + Counting 🔍 Platform: LeetCode Today’s challenge was to remove duplicates from a sorted array in-place, but this time allowing at most two occurrences of each element. Approach: ✔ Traverse the array and track occurrences using a counter ✔ Allow elements to appear at most twice ✔ Use a pointer k to place valid elements in the correct position ✔ Skip elements when they exceed the allowed count Time Complexity: O(n) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/gm2_CHbz 🔗 Code: https://lnkd.in/gKxuTbsG #100DaysOfCode #Day26 #Java #DSA #LeetCode #TwoPointers #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 49 of #100DaysOfLeetCode 💻✅ Solved #387. First Unique Character in a String problem in Java. Approach: • Created an array of size 26 to store the frequency of each character • Traversed the string and counted how many times each character appears • Traversed the string again to find first character with frequency equal to 1 • Returned the index of that character • If no unique character is found, returned -1 Performance: ✓ Runtime: 6 ms (Beats 84.58% submissions) ✓ Memory: 47.16 MB (Beats 36.29% submissions) Key Learning: ✓ Practiced using frequency arrays for string problems ✓ Learned how counting characters helps find unique elements efficiently ✓ Strengthened understanding of string traversal and indexing Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 20 📌 Problem: Remove Duplicates from Sorted Array 💻 Language: Java 🧠 Concept Used: Two Pointer Technique 🔍 Platform: LeetCode Today’s challenge was to remove duplicates from a sorted array in-place while keeping the relative order of elements the same. Approach: ✔ Use two pointers — one to traverse the array and another to track the position of unique elements ✔ Compare the current element with the previous one ✔ If they are different, place the element at the next unique position ✔ Time Complexity: O(n) ✔ Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/g83THPD6 🔗 Code: https://lnkd.in/gmrtpCRT #100DaysOfCode #Day20 #Java #DSA #LeetCode #TwoPointers #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 98 - #100DaysOfCode Today’s problem was all about string comparison and operations simulation in Java. 💡 Problem Insight: Given a list of operations like "++X", "X++", "--X", "X--", we need to compute the final value of X after performing all operations. ⚠️ One key learning today: In Java, always use .equals() for string comparison instead of ==. Using == compares references, not actual content — a very common mistake! 🧠 Approach: Initialize x = 0 Traverse through each operation Increment or decrement based on the operation string 📌 What I Improved Today: Better understanding of string handling in Java Avoiding common pitfalls in comparisons Writing cleaner conditional logic #Java #CodingJourney #LeetCode #100DaysOfCode #ProblemSolving #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