educative.io

Educative

https://www.educative.io/courses/algorithms-coding-interviews-java/B1DRLqNANnW#Tabulated-version-#2

Hi, inside the function fib, the condition should check if the input is less than or equal to 1, instead of equal to 0 and return n. for input 1 the current code returns 0 instead of 1.
correct code:
if (n <= 1)
return n;


Type your question above this line.

Course: https://www.educative.io/collection/10370001/5347133077061632
Lesson: https://www.educative.io/collection/page/10370001/5347133077061632/6732638071029760

Hello @Yerramsetty_Ganesh_D,

Yes, you are right. It should return 1 instead of 0. We have updated the course.
Thank you for pointing it out.

1 Like