2005. Subtree Removal Game with Fibonacci Tree
A Fibonacci tree is a binary tree created using the order function
order(n):
order(0)is the empty tree.order(1)is a binary tree with only one node.order(n)is a binary tree that consists of a root node with the left subtree asorder(n - 2)and the right subtree asorder(n - 1).Alice and Bob are playing a game with a Fibonacci tree with Alice staring first. On each turn, a player selects a node and removes that node and its subtree. The player that is forced to delete
rootloses.Given the integer
n, returntrueif Alice wins the game orfalseif Bob wins, assuming both players play optimally.A subtree of a binary tree
treeis a tree that consists of a node intreeand all of this node’s descendants. The treetreecould also be considered as a subtree of itself.
1 | class Solution { |