100 Days of Coding Challenge – Day 12 📌 Problem: Sort Even and Odd Indices Independently 💻 Language: Java 🧠 Concept Used: Array Manipulation + Sorting 🔍 Platform: LeetCode Today’s challenge was to sort elements at even indices in non-decreasing order and elements at odd indices in non-increasing order. Example: Input: [4,1,2,3] Output: [2,3,4,1] This problem improved my understanding of index-based manipulation and conditional sorting. 🔗 Problem Link: https://lnkd.in/gPgaF8zX 🔗 Code: https://lnkd.in/g39vqHiM #100DaysOfCode #Day12 #Java #DSA #LeetCode #Arrays #ProblemSolving #CodingJourney
Java Array Sorting Challenge: Even and Odd Indices
More Relevant Posts
-
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
-
-
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
-
-
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
-
-
100 Days of Coding Challenge – Day 18 📌 Problem: Is Subsequence 💻 Language: Java 🧠 Concept Used: Two Pointer Technique 🔍 Platform: LeetCode Today’s challenge was to determine whether a string s is a subsequence of another string t. A subsequence means the characters appear in the same order, but not necessarily consecutively. Approach: ✔ Use two pointers to traverse both strings ✔ If characters match, move both pointers ✔ Otherwise, move the pointer of the second string ✔ If all characters of s are matched, it is a valid subsequence ✔ Time Complexity: O(n) ✔ Space Complexity: O(1) This problem reinforced how powerful the two-pointer technique can be for efficient string traversal. 🔗 Problem Link: https://lnkd.in/g_43jvhm 🔗 Code: https://lnkd.in/gG_7d2BC #100DaysOfCode #Day18 #Java #DSA #LeetCode #TwoPointers #Strings #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 77 of 100: LeetCode Challenge – One Step Closer! 🚀 🎯 Problem: Combination Sum II 💡 Difficulty: Medium 🛠️ Language: Java 📌 Today’s win: Solved "Combination Sum II" — a follow-up to the previous combination problem, but this time with duplicates in the input and each number used only once per combination. 🧠 Approach: Sorted the array to handle duplicates easily Used backtracking with a "start" index to avoid reusing the same element Skipped duplicates during recursion to prevent repeated combinations 📊 Runtime: 8 ms (Beats 16.56%) 📦 Memory: 50.53 MB (Beats 5.73%) ✅ Passed all 176 test cases! 🔍 Key Takeaways: Sorting + backtracking is a classic combo for subset/combination problems Skipping duplicates in recursion is essential to avoid redundant results The "remain < 0" condition helps prune the search tree early 📈 74 days down, 26 to go — consistency is the real win! #LeetCode #100DaysOfCode #Java #CodingChallenge #Backtracking #CombinationSumII #ProblemSolving #CodeNewbie #DevCommunity #WomenWhoCode #LearnInPublic #DSA
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 21 📌 Problem: Word Pattern 💻 Language: Java 🧠 Concept Used: HashMap + String Mapping 🔍 Platform: LeetCode A valid pattern means there must be a one-to-one mapping (bijection) between characters in the pattern and words in the string. In other words: • Each pattern character maps to exactly one unique word • Each word maps to only one pattern character Example: pattern = "abba" s = "dog cat cat dog" → ✅ true Approach: ✔ Split the string into words using split(" ") ✔ Use a HashMap to map pattern characters to words ✔ Ensure no two characters map to the same word ✔ Verify consistency during traversal Time Complexity: O(n) Space Complexity: O(n) 🔗 Problem Link: https://lnkd.in/grDzg_82 🔗 Code: https://lnkd.in/gA9CCyc5 #100DaysOfCode #Day21 #Java #DSA #LeetCode #HashMap #Strings #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 34 of #100DaysOfLeetCode 💻✅ Solved #110. Balanced Binary Tree on LeetCode using Java. Approach: • Used a bottom-up recursive approach to calculate height • Returned -1 immediately if any subtree is unbalanced • Compared left and right subtree heights at each node • Checked if the height difference is greater than 1 • Stopped early to optimize unnecessary computations Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) ✓ Memory: 45.33 MB (Beats 95.41% submissions) Key Learning: ✓ Understood how to combine height calculation with balance checking ✓ Learned early termination technique in recursion ✓ Improved problem-solving for tree-based recursive problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinaryTree #Recursion #TreeProblems #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 7 / 100 – LeetCode Challenge Today I solved Length of Last Word (LeetCode #58) using Java. 🔹 Problem: Given a string "s" containing words and spaces, return the length of the last word in the string. 📌 Approach: - Traverse the string from the end. - Ignore trailing spaces. - Start counting characters of the last word. - Stop when a space appears after counting begins. 💡 Key Concepts Practiced: - String traversal - "charAt()" usage - Reverse iteration - Conditional logic ⏱ Time Complexity: O(n) 📦 Space Complexity: O(1) ✅ Key Takeaway: Sometimes solving a problem becomes easier when we traverse the data from the end instead of the beginning. #100DaysOfCode #LeetCode #Java #DSA #ProblemSolving #CodingJourney
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
-
-
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
-
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