Skip to content

Commit aacd779

Browse files
committed
Add greedy solution for Jump Game.
1 parent e47ca45 commit aacd779

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import grdJumpGame from '../grdJumpGame';
2+
3+
describe('grdJumpGame', () => {
4+
it('should solve Jump Game problem in greedy manner', () => {
5+
expect(grdJumpGame([1, 0])).toBeTruthy();
6+
expect(grdJumpGame([100, 0])).toBeTruthy();
7+
expect(grdJumpGame([2, 3, 1, 1, 4])).toBeTruthy();
8+
expect(grdJumpGame([1, 1, 1, 1, 1])).toBeTruthy();
9+
expect(grdJumpGame([1, 5, 2, 1, 0, 2, 0])).toBeTruthy();
10+
11+
expect(grdJumpGame([1, 0, 1])).toBeFalsy();
12+
expect(grdJumpGame([3, 2, 1, 0, 4])).toBeFalsy();
13+
expect(grdJumpGame([0, 0, 0, 0, 0])).toBeFalsy();
14+
expect(grdJumpGame([5, 4, 3, 2, 1, 0, 0])).toBeFalsy();
15+
});
16+
});

0 commit comments

Comments
 (0)