I'm trying to implement dp on a fibonacci sequence using vector.If i declare memo globally as an array with given size it runs fine.But while using vector it shows no output on the console. What seems to be the problem here?
#include<bits/stdc++.h>
using namespace std;
int fib(int n)
{
    vector<int>memo;
    int f;
    if(memo[n]!=0)
        return memo[n];
    if(n<=2)
        return 1;
    else
        f = fib(n-1)+fib(n-2);
    memo.push_back(f);
    return f;
}
int main()
{
    int num;
    cin>>num;
    cout<<fib(num);
}
 
     
     
     
    