My code is failing some test cases can u help me to identify and help in correction of my code
problem https://leetcode.com/problems/longest-arithmetic-subsequence/
my code
https://ide.codingblocks.com/s/577537
My code is failing some test cases can u help me to identify and help in correction of my code
problem https://leetcode.com/problems/longest-arithmetic-subsequence/
my code
https://ide.codingblocks.com/s/577537
This is because same numbers are considered more than once. For example your code fails for [7,7,7]. I corrected it https://ide.codingblocks.com/s/577696, I keep track of numbers we have already seen for a particular nums[i]. Also I started iterating backwards because it’s easier to comprehend, I am not sure if fiiling the future numbers works correctly(it should I guess, am not sure). So for now you have the best answers until index i.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.