One Line
# Complexity
- Time complexity:
$$O(1)$$

- Space complexity:
$$O(1)$$

# Code
```javascript []
const numberOfChild = (n, k) => (k %= n * 2 - 2) && k > n - 1 && 2 * n - 2 - k || k;
```
```typescript []
const numberOfChild = (n: number, k: number): number => (k %= n * 2 - 2) && k > n - 1 && 2 * n - 2 - k || k;
```
['Math', 'TypeScript', 'JavaScript']