Easy csharp

Climbing stairs 10 steps #22

Problem

Ways to climb 10 stairs (1 or 2 steps).

Hints
  • dp[i] = dp[i-1] + dp[i-2]

Your solution

TestStatusDetails
Ready — edit the code above and click Run or Submit.

Solution

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = 10;
        int a = 1, b = 1;
        for (int k = 2; k <= n; k++) { int t = a + b; a = b; b = t; }
        Console.WriteLine(b);
    }
}

Try solving on your own first, then reveal the official answer.

Explanation

Same as Fibonacci — classic DP intro.

Discussion

0

Sign in to join the discussion.

No discussions yet — ask the first question!

Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details