class Solution {
public int fib(int n) {
if (n<2) {
return n==1 ? 1:0;
}
int [] arr = new int [n+1];
arr[0] =0;
arr[1] =1;
for (int i=2;i<n+1;i++) {
arr[i] =arr[i-1] +arr[i-2];
}
return arr[n];
}
}