Solved LeetCode 119 – Pascal’s Triangle II with Java

🌟 Day 85 of My #100DaysOfCode Challenge 🧩 Problem: LeetCode 119 – Pascal’s Triangle II 🧠 Understanding the Problem We need to return the rowIndexth (0-indexed) row of Pascal’s Triangle. Each number is formed by adding the two numbers directly above it from the previous row. 📘 Example: Input: rowIndex = 3 Output: [1, 3, 3, 1] ⚙️ Approach Start with [1] as the first row. For each new row, update the list from right to left (so we don’t overwrite values that we still need). Append 1 at the end of each iteration to complete the row. 🕒 Complexity Time Complexity: O(n²) Space Complexity: O(n) ✅ (optimized — we use only one list) 💡 Key Learning This problem emphasizes in-place updates — a technique often used to optimize space in dynamic programming problems. ✨ Takeaway Building Pascal’s Triangle row by row mirrors how small consistent steps lead to structured growth — just like progress in coding! 🚀 💬 “Each layer of learning strengthens the next — one row at a time.” 💛 #Day85 #LeetCode #Java #DSA #DynamicProgramming #ProblemSolving #100DaysOfCode #CodingChallenge

  • graphical user interface, text, application

To view or add a comment, sign in

Explore content categories