Tap here to switch tabs
Problem
Submissions

Problem: Subtree Removal Game with Fibonacci Tree

med
30 min
Try to solve the Subtree Removal Game with Fibonacci Tree problem.

Statement

A Fibonacci tree is a binary tree defined recursively for an integer n:

  • An order 11 Fibonacci tree consists of a single root node.

  • An order 22 Fibonacci tree consists of a root node with a left child that is an order 11 Fibonacci tree.

  • An order n Fibonacci tree (n≥3n \geq 3) consists of a root node with a left child that is an order n−2n - 2 Fibonacci tree and a right child that is an order n−1n - 1 Fibonacci tree.

Alice and Bob play a game on an order n Fibonacci tree. Alice moves first, and players take turns. In each turn, a player selects any remaining node and removes that node along with its entire subtree. The player who removes the root node loses the game.

Assuming both players play optimally, return true if Alice wins the game, or false if Bob wins.

Constraints:

  • 1≤1 \leq n ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Subtree Removal Game with Fibonacci Tree

med
30 min
Try to solve the Subtree Removal Game with Fibonacci Tree problem.

Statement

A Fibonacci tree is a binary tree defined recursively for an integer n:

  • An order 11 Fibonacci tree consists of a single root node.

  • An order 22 Fibonacci tree consists of a root node with a left child that is an order 11 Fibonacci tree.

  • An order n Fibonacci tree (n≥3n \geq 3) consists of a root node with a left child that is an order n−2n - 2 Fibonacci tree and a right child that is an order n−1n - 1 Fibonacci tree.

Alice and Bob play a game on an order n Fibonacci tree. Alice moves first, and players take turns. In each turn, a player selects any remaining node and removes that node along with its entire subtree. The player who removes the root node loses the game.

Assuming both players play optimally, return true if Alice wins the game, or false if Bob wins.

Constraints:

  • 1≤1 \leq n ≤100\leq 100