Solved LeetCode 944 – Delete Columns to Make Sorted 🧠📊 This problem looks simple at first, but it’s a great reminder that clear thinking beats complex logic. 🔍 Problem in short: - You’re given multiple strings of equal length. Imagine them stacked one below another, forming a grid. Your task is to delete columns that are NOT lexicographically sorted from top to bottom and return how many such columns exist. 🧠 How I approached it: 1️⃣ First, I visualized the strings as a table where: - Each row is a string - Each column contains characters from all strings at that position 2️⃣ Then, I checked each column independently: - Start from the top row - Compare every character with the one directly below it 3️⃣ If at any point: - The upper character is greater than the one below → That column is not sorted 4️⃣ The moment a column fails this condition: - I mark it for deletion - Move on to the next column (no need to check further for that one) 5️⃣ Finally, I count how many columns were marked for deletion. ✨ Key takeaway - You don’t always need advanced data structures. - Sometimes, a simple comparison + clean iteration is all it takes. #LeetCode #DSA #ProblemSolving #Python #LearningInPublic #Consistency
Clear thinking > complex logic. Good solve 👏
Anjali Joshi Great approach! How do you tackle similar problems?