Skip to content

Commit ffa07a8

Browse files
committed
Fix all 5 Codacy static analysis issues
- Add curly braces to single-statement if blocks (lines 16, 28) - Split multi-statement lines into separate lines (lines 16, 28) - Declare variables separately instead of comma-separated (line 24)
1 parent 2d98762 commit ffa07a8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Algorithms/Other/BoyerMooreMajorityVote.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,27 @@ public static class BoyerMooreMajorityVote
1313
/// <returns>Majority element or null.</returns>
1414
public static int? FindMajority(int[] nums)
1515
{
16-
if (nums?.Length == 0) return null;
16+
if (nums?.Length == 0)
17+
{
18+
return null;
19+
}
1720

1821
var candidate = FindCandidate(nums!);
1922
return IsMajority(nums!, candidate) ? candidate : null;
2023
}
2124

2225
private static int FindCandidate(int[] nums)
2326
{
24-
int candidate = nums[0], count = 1;
27+
int candidate = nums[0];
28+
int count = 1;
2529

2630
for (int i = 1; i < nums.Length; i++)
2731
{
28-
if (count == 0) candidate = nums[i];
32+
if (count == 0)
33+
{
34+
candidate = nums[i];
35+
}
36+
2937
count += nums[i] == candidate ? 1 : -1;
3038
}
3139

0 commit comments

Comments
 (0)