Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

export function arrayManipulation(n, queries) {
function arrayManipulation(n, queries) {
const LENGTH = n + 1;
const SURROGATE_VALUE = 0;
const result = Array(LENGTH).fill(SURROGATE_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { logger as console } from '../../../logger.js';

import TEST_CASES from './cruch_testcases_test.json';

import { arrayManipulation } from './cruch_bruteforce.js';
import crush from './cruch_bruteforce.js';

describe('arrays: crush (bruteforce) small cases', () => {
it('arrayManipulation Test Cases', () => {
expect.assertions(3);

TEST_CASES.forEach((test) => {
const answer = arrayManipulation(test.n, test.queries);
const answer = crush.arrayManipulation(test.n, test.queries);

console.debug(
`arrayManipulation(${test.n}, ${test.queries}) solution found: ${answer}`
Expand Down
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, queries) {
function arrayManipulation(n, queries) {
// why adding 2?
// first slot to adjust 1-based index and
// last slot for storing accumSum result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { logger as console } from '../../../logger.js';

import TEST_CASES from './cruch_testcases_test.json';

import { arrayManipulation } from './cruch_optimized.js';
import crush from './cruch_optimized.js';

describe('arrays: crush (optimized)', () => {
it('arrayManipulation Test Cases', () => {
expect.assertions(3);

TEST_CASES.forEach((test) => {
const answer = arrayManipulation(test.n, test.queries);
const answer = crush.arrayManipulation(test.n, test.queries);

console.debug(
`arrayManipulation(${test.n}, ${test.queries}) solution found: ${answer}`
Expand Down