We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents eac33d4 + e8bc25b commit 602a955Copy full SHA for 602a955
src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.ts
@@ -3,18 +3,19 @@
3
*/
4
5
export const TOO_CHAOTIC_ERROR = 'Too chaotic';
6
+export const NEW_YEAR_CHAOS_TOLERANCE = 2;
7
8
export function minimumBribes(q: number[]): number {
9
let bribes = 0;
10
let i = 0;
11
12
q.forEach((value) => {
13
const position = i + 1;
- if (value - position > 2) {
14
+ if (value - position > NEW_YEAR_CHAOS_TOLERANCE) {
15
throw new Error(TOO_CHAOTIC_ERROR);
16
}
17
- const fragment = q.slice(Math.max(value - 2, 0), i);
18
+ const fragment = q.slice(Math.max(value - NEW_YEAR_CHAOS_TOLERANCE, 0), i);
19
20
fragment.forEach((k) => {
21
if (k > value) {
0 commit comments