From 40153cabc02c59ff8db07558adf01adefeecb293 Mon Sep 17 00:00:00 2001 From: Srihari Date: Thu, 12 Mar 2026 00:36:43 +0530 Subject: [PATCH] Update articles --- articles/height-checker.md | 47 +++++++++++++++++++ articles/pascals-triangle-ii.md | 10 ++-- articles/products-of-array-discluding-self.md | 2 +- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/articles/height-checker.md b/articles/height-checker.md index 65215ac40..e4616c97b 100644 --- a/articles/height-checker.md +++ b/articles/height-checker.md @@ -94,6 +94,25 @@ class Solution { } ``` +```csharp +public class Solution { + public int HeightChecker(int[] heights) { + int[] expected = new int[heights.Length]; + Array.Copy(heights, expected, heights.Length); + Array.Sort(expected); + + int res = 0; + for (int i = 0; i < heights.Length; i++) { + if (heights[i] != expected[i]) { + res++; + } + } + + return res; + } +} +``` + ```go func heightChecker(heights []int) int { expected := make([]int, len(heights)) @@ -283,6 +302,34 @@ class Solution { } ``` +```csharp +public class Solution { + public int HeightChecker(int[] heights) { + int[] count = new int[101]; + foreach (int h in heights) { + count[h]++; + } + + List expected = new List(); + for (int h = 1; h <= 100; h++) { + int c = count[h]; + for (int i = 0; i < c; i++) { + expected.Add(h); + } + } + + int res = 0; + for (int i = 0; i < heights.Length; i++) { + if (heights[i] != expected[i]) { + res++; + } + } + + return res; + } +} +``` + ```go func heightChecker(heights []int) int { count := make([]int, 101) diff --git a/articles/pascals-triangle-ii.md b/articles/pascals-triangle-ii.md index 55a25bd61..d5d97841f 100644 --- a/articles/pascals-triangle-ii.md +++ b/articles/pascals-triangle-ii.md @@ -101,7 +101,7 @@ class Solution { ```csharp public class Solution { - public IList GetRow(int rowIndex) { + public List GetRow(int rowIndex) { if (rowIndex == 0) return new List { 1 }; var curRow = new List { 1 }; @@ -262,7 +262,7 @@ class Solution { ```csharp public class Solution { - public IList GetRow(int rowIndex) { + public List GetRow(int rowIndex) { var res = new List(); for (int i = 0; i <= rowIndex; i++) { int[] row = new int[i + 1]; @@ -423,7 +423,7 @@ class Solution { ```csharp public class Solution { - public IList GetRow(int rowIndex) { + public List GetRow(int rowIndex) { var res = new List { 1 }; for (int i = 0; i < rowIndex; i++) { var nextRow = new List(new int[res.Count + 1]); @@ -571,7 +571,7 @@ class Solution { ```csharp public class Solution { - public IList GetRow(int rowIndex) { + public List GetRow(int rowIndex) { var row = new List(new int[rowIndex + 1]); for (int i = 0; i <= rowIndex; i++) row[i] = 1; for (int i = 1; i < rowIndex; i++) { @@ -707,7 +707,7 @@ class Solution { ```csharp public class Solution { - public IList GetRow(int rowIndex) { + public List GetRow(int rowIndex) { var row = new List { 1 }; for (int i = 1; i <= rowIndex; i++) { row.Add((int)((long)row[row.Count - 1] * (rowIndex - i + 1) / i)); diff --git a/articles/products-of-array-discluding-self.md b/articles/products-of-array-discluding-self.md index a7d67c6e1..e3910a34c 100644 --- a/articles/products-of-array-discluding-self.md +++ b/articles/products-of-array-discluding-self.md @@ -225,7 +225,7 @@ So we first check how many zeros the array has: - The index with zero gets the `prod` of all non-zero numbers. - All other positions get `0`. - If there are no zeros: - - Set each result value to `prod / nums[i]`. + - Set each result value to `prod // nums[i]`. 5. Return the result array. ::tabs-start