23. Rohan's Love for Matrix
My Approach
Time and Auxiliary Space Complexity
Code (C++)
class Solution {
public:
int firstElement(int n)
{
int prev1=0, prev2=1;
for (int i=2;i<=n;i++)
{
int curr=(prev1+prev2)%1000000007;
prev1=prev2;
prev2=curr;
}
return prev2;
}
};Contribution and Support
Last updated