Skip to content

Commit 97ddb9f

Browse files
authored
Merge pull request #184 from sir-gon/develop
Develop
2 parents d537f6b + b654e94 commit 97ddb9f

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

.vscode/settings.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
"[csharp]": {
88
"editor.defaultFormatter": "ms-dotnettools.csharp"
99
},
10-
"omnisharp.enableEditorConfigSupport": true,
10+
"[json]": {
11+
"editor.defaultFormatter": "esbenp.prettier-vscode"
12+
},
1113
"[github-actions-workflow]": {
1214
"editor.defaultFormatter": "esbenp.prettier-vscode"
1315
},
16+
"omnisharp.enableEditorConfigSupport": true,
1417
"snyk.advanced.additionalParameters": "--exclude=.trunk,coverage-report"
15-
}
18+
}

src/algorithm_exercises_csharp/hackerrank/interview_preparation_kit/arrays/TwoDArray.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ private static List<int> getHourGlass(List<List<int>> arr, int positionX, int po
3131

3232
public static int hourglassSum(List<List<int>> arr)
3333
{
34-
int matrixSize = 0;
35-
36-
if (arr.Count > 0)
37-
{
38-
matrixSize = arr.Count;
39-
}
34+
int matrixSize = arr.Count;
4035

4136
int matrixStartIndex = 1;
4237
int matrixEndIndex = matrixSize - 2;

src/algorithm_exercises_csharp_test/Resources/hackerrank/interview_preparation_kit/arrays/2d_array.testcases.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,29 @@
1010
[0, 0, 1, 2, 4, 0]
1111
],
1212
"expected": 19
13+
},
14+
{
15+
"title": "Sample Test Case 1",
16+
"input": [
17+
[1, 1, 1, 0, 0, 0],
18+
[0, 1, 0, 0, 0, 0],
19+
[1, 1, 1, 0, 0, 0],
20+
[0, 9, 2, -4, -4, 0],
21+
[0, 0, 0, -2, 0, 0],
22+
[0, 0, -1, -2, -4, 0]
23+
],
24+
"expected": 13
25+
},
26+
{
27+
"title": "Sample Test Case 2",
28+
"input": [
29+
[-9, -9, -9, 1, 1, 1],
30+
[0, -9, 0, 4, 3, 2],
31+
[-9, -9, -9, 1, 2, 3],
32+
[0, 0, 8, 6, 6, 0],
33+
[0, 0, 0, -2, 0, 0],
34+
[0, 0, 1, 2, 4, 0]
35+
],
36+
"expected": 28
1337
}
1438
]

src/algorithm_exercises_csharp_test/hackerrank/interview_preparation_kit/arrays/TwoDArray.Test.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,16 @@ public void testHourglassSum()
3333
Assert.AreEqual(test.expected, result);
3434
}
3535
}
36+
37+
38+
[TestMethod]
39+
public void testHourglassSumEdgeCases()
40+
{
41+
List<List<int>> input = [];
42+
int expected = 0;
43+
int result = TwoDArray.hourglassSum(input);
44+
45+
Assert.AreEqual(expected, result);
46+
}
3647
}
3748

0 commit comments

Comments
 (0)