Python3
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
from threading import Condition

class DiningPhilosophers:
    def __init__(self):
        self.forks = [True] * 5
        self.condition = Condition()

    # call the functions directly to execute, for example, eat()
    def wantsToEat(self,
                   philosopher: int,
                   pickLeftFork: 'Callable[[], None]',
                   pickRightFork: 'Callable[[], None]',
                   eat: 'Callable[[], None]',
                   putLeftFork: 'Callable[[], None]',
                   putRightFork: 'Callable[[], None]') -> None:
        with self.condition:
            self.condition.wait_for(lambda: self._can_eat(philosopher))
            pickLeftFork()
            pickRightFork()
            eat()
            putLeftFork()
            putRightFork()
    
    def _get_forks_indexes(self, philosopher: int) -> tuple[int, int]:
        left_fork_index = philosopher
        right_fork_index = left_fork_index - 1
        return left_fork_index, right_fork_index   

    def _can_eat(self, philosopher: int) -> bool:
        left_fork_index, right_fork_index = self._get_forks_indexes(philosopher)
        left_fork = self.forks[left_fork_index]
        right_fork = self.forks[right_fork_index]
        return left_fork and right_fork
```
['Python3']