title: Error: Abort signal from abort(3) (SIGABRT)
body: <p>Why is geeks for geeks giving an error on the following dynamic programming solution?
  The error is Abort signal from abort(3) (SIGABRT). Why most of my dp solution throw errors that way?
  Kindly tell and provide any helpful material to learn dp from.</p>
  <pre><code>int lis(int* arr, int n, int comp,int *dp) {
      if (n == -1)return 1;
      if (dp[comp * comp + n] != -1) {
          return dp[comp * comp + n];
      }
      if (arr[comp] &gt; arr[n])
          dp[comp * comp + n]= max(1 + lis(arr, n - 1, n,dp), lis(arr, n - 1, comp,dp));
      else
          dp[comp * comp + n]= lis(arr, n - 1, comp,dp);
      return dp[comp * comp + n];
  }
  
  
  int longestSubsequence(int n, int* arr) {
      int mxm = 0;
      int* dp = new int[n * n];
      memset(dp, -1, sizeof(dp)*n*n);
      while (n - 2 &gt;= 0) {
          mxm=max(mxm,lis(arr, n - 2, n - 1,dp));
          n--;
      }
      return mxm;
  }
  </code></pre>