Skip to content

Refactor #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
514fe50
[REFACTOR] root examples.
sir-gon Mar 12, 2025
bd7ff78
[REFACTOR] [Projecteuler] exercises.
sir-gon Mar 12, 2025
ddbad31
[REFACTOR] [Hacker Rank] warmup exercises.
sir-gon Mar 12, 2025
3da7652
[REFACTOR] [Hacker Rank] projecteuler exercises.
sir-gon Mar 12, 2025
0fcb6ec
[REFACTOR] [Hacker Rank] implementation exercises.
sir-gon Mar 12, 2025
a35b758
[REFACTOR] [Hacker Rank] libraries.
Mar 13, 2025
5cdd8db
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Array: 2D Array -…
sir-gon Mar 10, 2025
e42b925
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Arrays: Array Man…
sir-gon Mar 10, 2025
2b0237d
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Arrays: Left Rota…
sir-gon Mar 10, 2025
d0bbe0d
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Arrays: Minimum S…
sir-gon Mar 3, 2025
35b3f08
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Arrays: New Year …
sir-gon Mar 10, 2025
effe217
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Dictionaries and …
Feb 21, 2025
a29b249
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Dictionaries and …
sir-gon Mar 10, 2025
4218ea5
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Dictionaries and …
sir-gon Mar 10, 2025
15a4da7
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Dictionaries and …
sir-gon Mar 10, 2025
a564b0d
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Dictionaries and …
sir-gon Mar 10, 2025
bf80bbc
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Greedy Algorithms…
sir-gon Mar 10, 2025
f7e8f50
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Greedy Algorithms…
sir-gon Mar 10, 2025
f82fde3
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Greedy Algorithms…
sir-gon Mar 10, 2025
385bc44
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Dynamic Programmi…
sir-gon Mar 10, 2025
9ed2d1d
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Miscellaneous: Fr…
sir-gon Mar 12, 2025
8b9aa4f
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Recursion: Fibona…
sir-gon Mar 12, 2025
0741058
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Recursion: Davis'…
sir-gon Mar 12, 2025
0f93187
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Miscellaneous: Fl…
sir-gon Mar 12, 2025
ad7fd9f
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Recursion: Recurs…
sir-gon Mar 12, 2025
0b6e6ac
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Hash Tables: Ice …
sir-gon Mar 12, 2025
2c5f926
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Search: Swap Node…
sir-gon Mar 12, 2025
9f91e34
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Sorting: Bubble S…
sir-gon Mar 12, 2025
2284e55
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Sorting: Comparator.
sir-gon Mar 12, 2025
cfc2b12
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Sorting: Mark and…
sir-gon Mar 12, 2025
1d4bd7e
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Stacks and Queues…
sir-gon Mar 12, 2025
cfcdd89
[REFACTOR] [Hacker Rank] Interview Preparation Kit: String Manipulati…
sir-gon Mar 12, 2025
59c376f
[REFACTOR] [Hacker Rank] Interview Preparation Kit: String Manipulati…
sir-gon Mar 12, 2025
e3fe04e
[REFACTOR] [Hacker Rank]: Minimum Absolute Difference in an Array.
Mar 13, 2025
967f8f6
[REFACTOR] [Hacker Rank] Interview Preparation Kit: String Manipulati…
Mar 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/hackerrank/implementation/betweenTwoSets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @link Problem definition [[docs/hackerrank/implementation/betweenTwoSets.md]]
*/

export function isFactor(n: number, group: number[]): boolean {
function isFactor(n: number, group: number[]): boolean {
let result = true;
let i = 0;

Expand All @@ -19,7 +19,7 @@ export function isFactor(n: number, group: number[]): boolean {
return result;
}

export function factorOf(n: number, group: number[]): boolean {
function factorOf(n: number, group: number[]): boolean {
let result = true;
let i = 0;

Expand All @@ -36,7 +36,7 @@ export function factorOf(n: number, group: number[]): boolean {
return result;
}

export function getTotalX(a: number[], b: number[]): number {
function getTotalX(a: number[], b: number[]): number {
let max = 0;
for (const j of b) {
if (j > max) max = j;
Expand All @@ -53,4 +53,5 @@ export function getTotalX(a: number[], b: number[]): number {
return result.length;
}

export default { getTotalX };
export default { getTotalX, factorOf, isFactor };
export { getTotalX, factorOf, isFactor };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/birthday.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { logger as console } from '../../logger';

export function birthday(s: number[], d: number, m: number): number {
function birthday(s: number[], d: number, m: number): number {
let result = 0;
console.debug(`s: ${s.toString()}`);

Expand All @@ -23,3 +23,4 @@ export function birthday(s: number[], d: number, m: number): number {
}

export default { birthday };
export { birthday };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/bonAppetit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { logger as console } from '../../logger';

export function bonAppetit(bill: number[], k: number, b: number): string {
function bonAppetit(bill: number[], k: number, b: number): string {
const totalSum = bill.reduce(
(previousValue, currentValue) => previousValue + currentValue,
0
Expand All @@ -25,3 +25,4 @@ export function bonAppetit(bill: number[], k: number, b: number): string {
}

export default { bonAppetit };
export { bonAppetit };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/breakingRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @link Problem definition [[docs/hackerrank/implementation/breakingRecords.md]]
*/

export function breakingRecords(scores: number[]): number[] {
function breakingRecords(scores: number[]): number[] {
if (scores.length === 0) {
throw new Error('Empty input');
}
Expand All @@ -29,3 +29,4 @@ export function breakingRecords(scores: number[]): number[] {
}

export default { breakingRecords };
export { breakingRecords };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/countApplesAndOranges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @link Problem definition [[docs/hackerrank/implementation/countApplesAndOranges.md]]
*/

export function countApplesAndOranges(
function countApplesAndOranges(
s: number,
t: number,
a: number,
Expand Down Expand Up @@ -33,3 +33,4 @@ export function countApplesAndOranges(
}

export default { countApplesAndOranges };
export { countApplesAndOranges };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/countingValleys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { logger as console } from '../../logger';

export function countingValleys(steps: number, path: string): number {
function countingValleys(steps: number, path: string): number {
const stepList = path.split('');
let altitude = 0;
let valleys = 0;
Expand All @@ -27,3 +27,4 @@ export function countingValleys(steps: number, path: string): number {
}

export default { countingValleys };
export { countingValleys };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/dayOfProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MonthNumbers, daysInMonthNumber } from '../../constants';
const zeroPad = (num: number, places: number): string =>
String(num).padStart(places, '0');

export function dayOfProgrammer(year: number): string {
function dayOfProgrammer(year: number): string {
const dayToSearch = 256;
let leap: number;

Expand Down Expand Up @@ -52,3 +52,4 @@ export function dayOfProgrammer(year: number): string {
}

export default { dayOfProgrammer };
export { dayOfProgrammer };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/divisibleSumPairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { logger as console } from '../../logger';

export function divisibleSumPairs(n: number, k: number, ar: number[]): number {
function divisibleSumPairs(n: number, k: number, ar: number[]): number {
let pairs = 0;
for (let i = 0; i < ar.length; i++) {
for (let j = i + 1; j < ar.length; j++) {
Expand All @@ -19,3 +19,4 @@ export function divisibleSumPairs(n: number, k: number, ar: number[]): number {
}

export default { divisibleSumPairs };
export { divisibleSumPairs };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/gradingStudents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @link Problem definition [[docs/hackerrank/implementation/gradingStudents.md]]
*/

export function gradingStudents(grades: number[]): number[] {
function gradingStudents(grades: number[]): number[] {
const minimum = 38;
const roundTo = 5;
const result: number[] = [];
Expand All @@ -23,3 +23,4 @@ export function gradingStudents(grades: number[]): number[] {
}

export default { gradingStudents };
export { gradingStudents };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/jumpingOnClouds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { logger as console } from '../../logger';

export function jumpingOnClouds(c: number[]): number {
function jumpingOnClouds(c: number[]): number {
let result = 0;
let key = 0;

Expand All @@ -26,3 +26,4 @@ export function jumpingOnClouds(c: number[]): number {
}

export default { jumpingOnClouds };
export { jumpingOnClouds };
8 changes: 2 additions & 6 deletions src/hackerrank/implementation/kangaroo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
* @link Problem definition [[docs/hackerrank/implementation/kangaroo.md]]
*/

export function kangaroo(
x1: number,
v1: number,
x2: number,
v2: number
): string {
function kangaroo(x1: number, v1: number, x2: number, v2: number): string {
if (v1 === v2) {
if (x1 !== x2) return 'NO';
return 'YES';
Expand All @@ -23,3 +18,4 @@ export function kangaroo(
}

export default { kangaroo };
export { kangaroo };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/migratoryBirds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { logger as console } from '../../logger';

type Birds = Record<string, number>;

export function migratoryBirds(arr: number[]): number {
function migratoryBirds(arr: number[]): number {
if (arr.length === 0) {
throw new Error('Empty input');
}
Expand Down Expand Up @@ -36,3 +36,4 @@ export function migratoryBirds(arr: number[]): number {
}

export default { migratoryBirds };
export { migratoryBirds };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/minimumAbsoluteDifference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { logger as console } from '../../logger';

export function minimumAbsoluteDifference(arr: number[]): number {
function minimumAbsoluteDifference(arr: number[]): number {
if (arr.length === 0) {
throw new Error('Empty input');
}
Expand All @@ -31,3 +31,4 @@ export function minimumAbsoluteDifference(arr: number[]): number {
}

export default { minimumAbsoluteDifference };
export { minimumAbsoluteDifference };
7 changes: 4 additions & 3 deletions src/hackerrank/implementation/repeatedString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { logger as console } from '../../logger';

export function countAs(word: string): number {
function countAs(word: string): number {
let result = 0;

const chars = word.split('');
Expand All @@ -18,7 +18,7 @@ export function countAs(word: string): number {
return result;
}

export function repeatedString(s: string, n: number): number {
function repeatedString(s: string, n: number): number {
let result = 0;

const blockSize = s.length;
Expand All @@ -32,4 +32,5 @@ export function repeatedString(s: string, n: number): number {
return result;
}

export default { countAs };
export default { countAs, repeatedString };
export { countAs, repeatedString };
3 changes: 2 additions & 1 deletion src/hackerrank/implementation/sockMerchant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { logger as console } from '../../logger';

export function sockMerchant(n: number, ar: number[]): number {
function sockMerchant(n: number, ar: number[]): number {
let result = 0;

type Matches = Record<string, number>;
Expand All @@ -27,3 +27,4 @@ export function sockMerchant(n: number, ar: number[]): number {
}

export default { sockMerchant };
export { sockMerchant };
5 changes: 3 additions & 2 deletions src/hackerrank/interview_preparation_kit/arrays/2d_array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/2d_array.md]]
*/

export function gethourGlass(
function gethourGlass(
arr: number[][],
positionX: number,
positionY: number
Expand All @@ -22,7 +22,7 @@ export function gethourGlass(
return result;
}

export function hourglassSum(arr: number[][]): number | null {
function hourglassSum(arr: number[][]): number | null {
let matrixSize = 0;

if (arr?.[0]) {
Expand Down Expand Up @@ -65,3 +65,4 @@ export function hourglassSum(arr: number[][]): number | null {
}

export default { hourglassSum };
export { hourglassSum };
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { logger as console } from '../../../logger';

export function arrayManipulation(n: number, queries: number[][]): number {
function arrayManipulation(n: number, queries: number[][]): number {
const LENGTH = n + 1;
const SURROGATE_VALUE = 0;
const result: number[] = Array<number>(LENGTH).fill(SURROGATE_VALUE);
Expand All @@ -29,3 +29,4 @@ export function arrayManipulation(n: number, queries: number[][]): number {
}

export default { arrayManipulation };
export { arrayManipulation };
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @link Problem definition [[docs/hackerrank/interview_preparation_kit/arrays/crush.md]]
*/

export function arrayManipulation(n: number, queries: number[][]): number {
function arrayManipulation(n: number, queries: number[][]): number {
// why adding 2?
// first slot to adjust 1-based index and
// last slot for storing accumSum result
Expand All @@ -29,3 +29,4 @@ export function arrayManipulation(n: number, queries: number[][]): number {
}

export default { arrayManipulation };
export { arrayManipulation };
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,30 @@
"title": "Sample Test Case 0",
"n": 5,
"queries": [
[
1,
2,
100
],
[
2,
5,
100
],
[
3,
4,
100
]
[1, 2, 100],
[2, 5, 100],
[3, 4, 100]
],
"expected": 200
},
{
"title": "Sample Test Case 1",
"n": 10,
"queries": [
[
1,
5,
3
],
[
4,
8,
7
],
[
6,
9,
1
]
[1, 5, 3],
[4, 8, 7],
[6, 9, 1]
],
"expected": 10
},
{
"title": "Sample Test Case 3",
"n": 10,
"queries": [
[
2,
6,
8
],
[
3,
5,
7
],
[
1,
8,
1
],
[
5,
9,
15
]
[2, 6, 8],
[3, 5, 7],
[1, 8, 1],
[5, 9, 15]
],
"expected": 31
}
Expand Down
Loading