Tabs and Spaces (Climbing Stairs) - aloalgo

Tabs and Spaces (Climbing Stairs)

Medium

You are given an integer n, representing a target space length.

Your task is to calculate the number of distinct ways to achieve the target space length n using individual spaces (which have a length of 1) and tabs (which have a length of 2).

You may assume that:

  • n will be a non-negative integer.

Return the total number of distinct ways.

Example 1

Input
4
Output
5
Explanation:

There are five distinct ways:

  1. ssss
  2. sst
  3. sts
  4. tss
  5. tt
Loading...
Input
4
Output
5

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!