From aacd7795d690439c3fb4f54fe6d90b71931ab95e Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Mon, 9 Jul 2018 18:00:09 +0300 Subject: [PATCH] Add greedy solution for Jump Game. --- .../jump-game/__test__/grdJumpGame.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/algorithms/uncategorized/jump-game/__test__/grdJumpGame.test.js diff --git a/src/algorithms/uncategorized/jump-game/__test__/grdJumpGame.test.js b/src/algorithms/uncategorized/jump-game/__test__/grdJumpGame.test.js new file mode 100644 index 00000000..f9339f68 --- /dev/null +++ b/src/algorithms/uncategorized/jump-game/__test__/grdJumpGame.test.js @@ -0,0 +1,16 @@ +import grdJumpGame from '../grdJumpGame'; + +describe('grdJumpGame', () => { + it('should solve Jump Game problem in greedy manner', () => { + expect(grdJumpGame([1, 0])).toBeTruthy(); + expect(grdJumpGame([100, 0])).toBeTruthy(); + expect(grdJumpGame([2, 3, 1, 1, 4])).toBeTruthy(); + expect(grdJumpGame([1, 1, 1, 1, 1])).toBeTruthy(); + expect(grdJumpGame([1, 5, 2, 1, 0, 2, 0])).toBeTruthy(); + + expect(grdJumpGame([1, 0, 1])).toBeFalsy(); + expect(grdJumpGame([3, 2, 1, 0, 4])).toBeFalsy(); + expect(grdJumpGame([0, 0, 0, 0, 0])).toBeFalsy(); + expect(grdJumpGame([5, 4, 3, 2, 1, 0, 0])).toBeFalsy(); + }); +});