title: What is the time complexity of this dfs algorithm
body: <p><strong>Problem Statement</strong>: Given an array of non-negative integers, you are initially positioned at the first index of the array. // A leetcode problem</p>
  <p>I was just confused about calculating the complexities of it. What is the tike complexity and could you please recommend any books or tutorial that teaches calculation of tie complexity</p>
  <pre><code>   class Solution {
      public boolean canJump(int[] nums,int sum,boolean isreach[]) {
          if(sum == nums.length-1){
              return true;
          }
          if(sum &gt;= nums.length){
              return false;
          }
          if(isreach[sum]) return true;
          int j = nums[sum];
          int k = 1;
          boolean check = false;
          while( k &lt;= j &amp;&amp; sum + k &lt; nums.length ){       
             check = check || canJump(nums, sum+k,isreach);
             if(check) {isreach[sum] = check; return true;}
             k++;
          }
          return false;
      }
      public boolean canJump(int[] nums) {
          boolean isreach[] = new boolean[nums.length];
          return canJump(nums,0,isreach);
      }
   }
  </code></pre>
  <p>In my opinion, it is n^2</p>