What I am doing wrong?

I am trying to solve a Dynamic Programming problem. I made the recursive function which is working correctly but when I am using memoization then I am getting wrong answer. Please tell me what I am doing wrong? Thank You.
Here is the problem : https://practice.geeksforgeeks.org/problems/maximum-tip-calculator/0
Here is my solution: https://ideone.com/4M8UKE

I think you mean to zero-initialize the aTip array instead of zeroing the array rTip twice in your init() function.

you don’t need a DP approach for this problem.
see this O(n) approach.

I am getting wrong answer for the first test case also. After correcting the init() function. Still getting wrong answer.

I want to learn DP that’s why I am solving currently dp problems only and try to solve them with dp approach.

A small correction, you are sorting so it would be O(n log n)