#Day-105) LeetCode Problem #944: Delete Columns to Make Sorted ✨ Today I solved an interesting problem that checks whether columns in a grid of strings are lexicographically sorted. If not, we count how many need to be deleted. 🔹 Approach: Iterate column by column Compare characters row by row Increment count if any column is unsorted 💻 Java Solution: (Attached in the image 👇) 🔑 Takeaway: This problem reinforces the importance of string manipulation and nested iteration logic. Even simple-looking problems can sharpen our ability to think in terms of grids and constraints. #LeetCode #Java #ProblemSolving #CodingChallenge #MERN #BackendDevelopment #LearningEveryday
Delete Columns to Make Sorted Grid LeetCode Problem
More Relevant Posts
-
#100DayCodingChallenge #Day53 🔹 Problem Solved: Sorting Strings in Reverse Order using Java Streams I recently solved a problem where the goal was to sort a list of strings in reverse (descending) alphabetical order using Java 8 Streams. Here’s a clear breakdown of how the solution works: ✅ Explanation (Step by Step) A list of strings is created containing multiple fruit names. Instead of using traditional loops or Collections.sort(), the Java Stream API is used for a cleaner and more modern approach. The list is converted into a stream, which allows functional-style operations. A sorting operation is applied using a reverse order comparator, which changes the default ascending sort to descending. The sorted elements are then collected back into a new list. Finally, the result is printed, showing the strings sorted in reverse alphabetical order. #100daysCodingChallenge #ProblemSolving #java #Coding #Day53
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
-
-
🚰Method Overloading (Compile-Time Polymorphism || Static Polymorphism + Early Binding ) Same method name, but different inputs → Java chooses the correct one ✅ ✅ It is called Compile-Time Polymorphism because the compiler decides which method to call based on arguments. ✅ Overloading Rules, You CAN overload by changing: ✅ Number of parameters ✅ Data types of parameters ✅ Order of parameters ✅data type order swap IS overloading ❌ You CANNOT overload by changing ONLY: ❌ Return type (NOT enough) ✅ Because Java doesn’t look at return type while calling a method. 🚫 You CANNOT overload a method by only changing return type Because method calling depends on: ✅ method name + parameters Return type is NOT used to decide the call. 🔖Frontlines EduTech (FLM) #Java #CoreJava #OOPS #Polymorphism #MethodOverloading #CompileTimePolymorphism #ConstructorOverloading #JVM #JavaDeveloper #FullStackDeveloper #LearningInPublic
To view or add a comment, sign in
-
-
🚀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 93/100 #leetcodegrind “Find Minimum in a Sorted Rotated Array” problem — a classic example of Binary Search in action. 💡 Key idea: In a rotated sorted array, the minimum element is the pivot. By comparing mid and high elements, we can efficiently narrow the search space to find the minimum in O(log n) time. 🧠 What I practiced: Binary search on rotated arrays Identifying the pivot element efficiently Handling edge cases like non-rotated arrays Writing clean and optimized Java code It’s a simple problem, but it reinforces the power of binary search in non-traditional ways. Rotation? No problem! 🔄🚀 #DSA #ProblemSolving #Java #BinarySearch #Arrays #LeetCode #CodingPractice #DailyLearning
To view or add a comment, sign in
-
-
This Java nested loop prints a step-based number pattern, helping me understand how small changes in loop conditions create different outputs. Each pattern strengthens: ✔ Logical thinking ✔ Control over nested loops ✔ Problem-solving approach Basics done right lead to long-term growth 💻🔥 👉 Consistency over perfection #Java #NestedLoops #PatternProgramming #ProgrammingLogic #JavaBasics #CodingJourney #LearnByDoing #DeveloperMindset
To view or add a comment, sign in
-
-
Today I revised the static keyword in Java and cleared a few common misconceptions. - Static Block It runs once when the class is loaded, not when the JVM starts. It executes before main() and before any object is created. - Static Methods Static methods cannot be overridden. They belong to the class, so method calls are decided at compile time method hiding. - Static Variables Static variables are shared across all objects and can change. Only static final variables act like constants. Small concepts, but very important for interviews and real-world Java coding, stay tuned for more tech posts ! 🤩 #Java #LearningJava #OOP #Programming #JavaDeveloper
To view or add a comment, sign in
-
Problem 744: Find Smallest Letter Greater Than Target Key Takeaways: Efficiency: Used O(logn) time complexity to find the smallest character strictly greater than the target. The Modulo Trick: Instead of complex if logic, used start % letters.length to handle the wrap-around case when no greater character exists. #LeetCode #Java #BinarySearch
To view or add a comment, sign in
-
-
Just solved **LeetCode 219: Contains Duplicate II** (Easy) using a clean **sliding window + HashSet** approach in Java! 🚀 The key insight: Maintain a set of at most (k+1) recent elements. If you encounter a duplicate before sliding out older ones, the indices are guaranteed to be ≤ k apart. java class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { Set<Integer> set = new HashSet<>(); for (int i = 0; i < nums.length; i++) { // If we've already seen this number in the current window, it's a duplicate! if (set.contains(nums[i])) { return true; } // Add the current number to the set (window) set.add(nums[i]); // If the window is too big (more than k+1 elements), remove the oldest one if (set.size() > k) { set.remove(nums[i - k]); } } return false; // No nearby duplicates found } } - Time: O(n) - Space: O(k) What's your favorite sliding window problem? Drop it below! 👇 #LeetCode #Coding #DataStructures #Algorithms #Java #SystemDesign #Tech #InterviewPrep
To view or add a comment, sign in
-
-
✅ Can we overload main()? YES ✅ ✅ You can overload main() in Java But ⚠️ JVM runs only, execute this one 👇: ✅ public static void main(String[] args) 🔥 Other main() methods will run ONLY if you call them manually ✅ JVM runs only String[] version, if it is removed, the java run option disappears Other mains run only when you call them 👉 You can overload main(), but JVM executes only main(String[] args) 🔖Frontlines EduTech (FLM) #Java #CoreJava #OOPS #Polymorphism #MethodOverloading #CompileTimePolymorphism #ConstructorOverloading #JVM #JavaDeveloper #FullStackDeveloper #LearningInPublic #mainOverloading
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