Day 3 of #120DaysOfCode🚀 📌Problem: Replace Elements with Greatest Element on Right Side 📌Language: Java 🔍Approach 1. Maintain a variable maxRight 2. Initially set it to -1 (for last element) 3. Traverse from the end 4. For each element . Save current value . Replace it with maxRight . Update maxRight ⏱️Time & Space Complexity Time Complexity: O(n) Space complexity: O(1) #120DaysOfCode #Day3 #Java #Arrays #DSA #ProblemSolving #Consistenncy #LearningEverday #LearninhPublic #Leetcode
Replace Elements with Greatest Element on Right Side in Java
More Relevant Posts
-
🚀Day 5 of #120DaysOfCode 📌 Problem: Height Checker 📌 Language: Java 🔍Approach(Two Pointer Technique) 1. make a copy of heights 2. Sort the copy --> this becomes expected 3. Traverse both arrays 4. Count indices where values differ 🔥 Key Insight 1. Create the expected order by sorting a copy of heights 2. Compare both arrays index by index 3. Count mismatches ⏱️ Time and Space Complexity Time Complexity: O(n log n) Space complexity: O(n) 🔥One problem closer to mastery #120DaysOfCode #Day5 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
To view or add a comment, sign in
-
-
🚀Day 13 of #120DaysOfCode 📌 Problem: Reverse String(344) 📌 Language: Java 🔍Approach(Two Pointer Technique) 1. Use two pointer . left --> start of the array index . right --> end of the array 2. While left < right: . Swaps[left] and s[right] . Move left forward (left++) . Move right backward (right--) 3. Stop when pointers meet or cross ⏱️ Time and Space Complexity Time Complexity: O(n) Space complexity: O(1) 🔥One problem closer to mastery #120DaysOfCode #Day13 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #Akshay #DSA
To view or add a comment, sign in
-
-
🚀Day 7 of #120DaysOfCode 📌 Problem: Find all numbers disappeared in an Array(448) 📌 Language: Java 🔍Approach: Using HashSet . Store all elements of nums in a set . Loop from 1 to n . If a number is not in the set --> it's missing ⏱️ Time and Space Complexity Time Complexity: O(n) Space complexity: O(n) 🔥One problem closer to mastery #120DaysOfCode #Day6 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
To view or add a comment, sign in
-
-
🚀Day 9 of #120DaysOfCode 📌 Problem: Largest Number At Least Twice of Others(747) 📌 Language: Java 🔍Approach 1. Traverse the array once to find the largest (max1) and second largest (max2) elements. 2. While updating the largest element, also store it's index. 3. After traversal, check if max >= 2 * max2 4. If true, return the stored index; otherwise, return -1. ⏱️ Time and Space Complexity Time Complexity: O(n) Space complexity: O(1) 🔥One problem closer to mastery #120DaysOfCode #Day9 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
To view or add a comment, sign in
-
-
🚀Day 14 of #120DaysOfCode 📌 Problem: Matrix Reshape(566) 📌 Language: Java 🔍Approach 1. Check if Reshape is possible 2. Traverse the original matrix in row order 3. Mapping logic ⏱️ Time and Space Complexity Time Complexity: O(m x n) Space complexity: O(r x c) 🔥One problem closer to mastery #120DaysOfCode #Day14 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
To view or add a comment, sign in
-
-
🚀Day 6 of #120DaysOfCode 📌 Problem: Third Maximum number(414) 📌 Language: Java 🔍Approach . Duplicates must be ignored . Sorting is easy but not optimal . We only need top 3 distinct values 🔥 Approaches Maintain three variable . max1 --> largest . max2 --> second largest . max3 --> third largest ⏱️ Time and Space Complexity Time Complexity: O(n) Space complexity: O(1) 🔥One problem closer to mastery #120DaysOfCode #Day6 #Java #Array #Leetcode #ProblemSolving #Consistency #LearningEveryday #LearningPublic #DSA
To view or add a comment, sign in
-
-
🚀Java practice - Day 72 Completed! 👍 Problem: Check if All Characters Have Equal Number of Occurrences Language: Java Today’s problem focused on validating whether all characters in a string appear the same number of times. A simple concept, but it required careful frequency tracking and comparison.✨ #Day72 #Java #LeetCode #Strings #HashMap #ProblemSolving #DailyCoding #Consistency #100DaysOfCode
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
-
-
🚀 Day 29 | #100Days100ProgrammingChallenge #Language: Java * Concept: Sorting Algorithm – Selection Sort #Today, I implemented Selection Sort using Java 🧑💻✨ #What the program does: * Takes number of elements from the user * Accepts array elements using Scanner * Sorts the array using Selection Sort algorithm * Displays the sorted array in ascending order #Key learnings today: * Better understanding of nested for loops * How Selection Sort works step-by-step * Swapping elements using a temporary variable * Improved logic-building skills #Sample Output: Input : 12 13 22 123 3 Output : 3 12 13 22 123 * Consistency is the key. Moving forward to Day 30 🚀 #Day29 #Java #SelectionSort #DSA #LearningJava #100DaysOfCode #ProgrammingChallenge
To view or add a comment, sign in
-
-
Day: 32/365 📌 LeetCode POTD: Minimum Deletions to make string balanced Medium Key takeaways/Learnings from this problem: 1. Using a stack makes the imbalance obvious—you directly see where a b is messing up the order before an a. 2. Big takeaway: sometimes simulating the process cleanly is easier than mathy DP, and still gives an optimal result. #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