From 81027a8c89f9f9f21068faf34efff5a11811c880 Mon Sep 17 00:00:00 2001 From: Ketan Agnihotri Date: Fri, 9 Sep 2022 15:48:03 +0530 Subject: [PATCH] Create 55-Jump-Game.cs --- csharp/55-Jump-Game.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 csharp/55-Jump-Game.cs diff --git a/csharp/55-Jump-Game.cs b/csharp/55-Jump-Game.cs new file mode 100644 index 000000000..476aa0107 --- /dev/null +++ b/csharp/55-Jump-Game.cs @@ -0,0 +1,14 @@ +public class Solution { + public bool CanJump(int[] nums) { + int goal = nums.Length - 1; + for (int i = nums.Length-1; i>=0; i--) + { + if (nums[i] + i >= goal) + { + goal = i; + } + } + + return goal == 0 ; + } +}