Skip to content

Commit 8164eee

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] ESLint manual fixes
1 parent b61db94 commit 8164eee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+256
-223
lines changed

src/hackerrank/implementation/breakingRecords.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
export function breakingRecords(scores: number[]): number[] {
6-
if (scores.length == 0) {
6+
if (scores.length === 0) {
77
throw new Error('Empty input');
88
}
99

src/hackerrank/implementation/kangaroo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export function kangaroo(
88
x2: number,
99
v2: number
1010
): string {
11-
if (v1 == v2) {
12-
if (x1 != x2) return 'NO';
11+
if (v1 === v2) {
12+
if (x1 !== x2) return 'NO';
1313
return 'YES';
1414
}
1515

src/hackerrank/implementation/migratoryBirds.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface Birds {
99
}
1010

1111
export function migratoryBirds(arr: number[]): number {
12-
if (arr.length == 0) {
12+
if (arr.length === 0) {
1313
throw new Error('Empty input');
1414
}
1515

@@ -28,7 +28,7 @@ export function migratoryBirds(arr: number[]): number {
2828
console.debug(`bird = ${bird} ~> map[bird] = ${map[bird]}`);
2929
console.debug(`max = ${max} ~> map[max] = ${map[max]}`);
3030

31-
if (map[bird] > map[max] || (map[bird] == map[max] && bird < max))
31+
if (map[bird] > map[max] || (map[bird] === map[max] && bird < max))
3232
max = bird;
3333
}
3434

src/hackerrank/implementation/minimumAbsoluteDifference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { logger as console } from '../../logger';
66

77
export function minimumAbsoluteDifference(arr: number[]): number {
8-
if (arr.length == 0) {
8+
if (arr.length === 0) {
99
throw new Error('Empty input');
1010
}
1111

src/hackerrank/implementation/sockMerchant.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export function sockMerchant(n: number, ar: number[]): number {
1919

2020
console.debug(matches);
2121

22-
for (const k in matches) {
23-
console.debug(matches[k]);
22+
for (const match of Object.values(matches)) {
23+
console.debug(match);
2424

25-
result += Math.floor(matches[k] / 2);
25+
result += Math.floor(match / 2);
2626
}
2727

2828
return result;

src/hackerrank/interview_preparation_kit/arrays/cruch_bruteforce.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect, it } from '@jest/globals';
22
import { logger as console } from '../../../logger';
33

4-
import { default as TEST_CASES } from './cruch_testcases_test.json';
4+
import TEST_CASES from './cruch_testcases_test.json';
55

66
import { arrayManipulation } from './cruch_bruteforce';
77

src/hackerrank/interview_preparation_kit/arrays/cruch_bruteforce.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export function arrayManipulation(n: number, queries: number[][]): number {
1212
let maximum = 0;
1313

1414
queries.forEach((query) => {
15-
const [a_start, b_end, k_value] = query;
15+
const [aStart, bEnd, kValue] = query;
1616
console.debug(`start -> ${result}`);
1717

18-
for (let i = a_start; i <= b_end; i++) {
19-
result[i] += k_value;
18+
for (let i = aStart; i <= bEnd; i++) {
19+
result[i] += kValue;
2020
console.debug(`result -> ${result}`);
2121
}
2222
});
@@ -27,3 +27,5 @@ export function arrayManipulation(n: number, queries: number[][]): number {
2727

2828
return maximum;
2929
}
30+
31+
export default { arrayManipulation };

src/hackerrank/interview_preparation_kit/arrays/cruch_optimized.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect, it } from '@jest/globals';
22
import { logger as console } from '../../../logger';
33

4-
import { default as TEST_CASES } from './cruch_testcases_test.json';
4+
import TEST_CASES from './cruch_testcases_test.json';
55

66
import { arrayManipulation } from './cruch_optimized';
77

src/hackerrank/interview_preparation_kit/arrays/cruch_optimized.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@
55
export function arrayManipulation(n: number, queries: number[][]): number {
66
// why adding 2?
77
// first slot to adjust 1-based index and
8-
// last slot for storing accum_sum result
8+
// last slot for storing accumSum result
99
const LENGTH = n + 2;
1010
const INITIAL_VALUE = 0;
1111
const result = Array(LENGTH).fill(INITIAL_VALUE);
1212
let maximum = 0;
1313

1414
queries.forEach((query) => {
15-
const [a_start, b_end, k_value] = query;
15+
const [aStart, bEnd, kValue] = query;
1616

17-
result[a_start] += k_value;
18-
result[b_end + 1] -= k_value;
17+
result[aStart] += kValue;
18+
result[bEnd + 1] -= kValue;
1919
});
2020

21-
let accum_sum = 0;
21+
let accumSum = 0;
2222

2323
result.forEach((value) => {
24-
accum_sum += value;
25-
maximum = Math.max(maximum, accum_sum);
24+
accumSum += value;
25+
maximum = Math.max(maximum, accumSum);
2626
});
2727

2828
return maximum;
2929
}
30+
31+
export default { arrayManipulation };

src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
* @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.md]]
33
*/
44

5-
export function rotLeftOne(a_numbers: number[]): number[] {
6-
const first = a_numbers.shift();
7-
if (first != undefined) {
8-
a_numbers.push(first);
5+
export function rotLeftOne(aNumbers: number[]): number[] {
6+
const first = aNumbers.shift();
7+
if (first !== undefined) {
8+
aNumbers.push(first);
99
}
1010

11-
return a_numbers;
11+
return aNumbers;
1212
}
1313

14-
export function rotLeft(a_numbers: number[], d_rotations: number): number[] {
15-
let output = [...a_numbers];
14+
export function rotLeft(aNumbers: number[], dRotations: number): number[] {
15+
let output = [...aNumbers];
1616

17-
for (let i = 0; i < d_rotations; i++) {
17+
for (let i = 0; i < dRotations; i++) {
1818
output = rotLeftOne(output);
1919
}
2020

0 commit comments

Comments
 (0)