Post

leetcode(리트코드)4월15일 challenge509-Fibonacii Number

leetcode April 15일 - Fibonacii Number 문제입니다.

1. 문제

https://leetcode.com/problems/fibonacci-number/


2. Input , Output


3. 분류 및 난이도

Eazy 난이도입니다.
4월 15일자 챌린지 문제입니다.


4. 문제 해석

  • 피보나치 수열
  • DP사용

5. code

c++

1
2
3
4
5
6
7
8
9
10
class Solution {
public:
    int DP[31] = {};
    int fib(int n) {
        if(n==0) return 0;
        if(n==1) return 1;
        if(DP[n]!=0) return DP[n];
        return DP[n] = fib(n-1) + fib(n-2);
    }
};

6. 결과 및 후기, 개선점

This post is licensed under CC BY 4.0 by the author.