<p>You are given two <strong>positive</strong> integers <code>n</code> and <code>k</code>. There are <code>n</code> children numbered from <code>0</code> to <code>n - 1</code> standing in a queue <em>in order</em> from left to right.</p>
<p>Initially, child 0 holds a ball and the direction of passing the ball is towards the right direction. After each second, the child holding the ball passes it to the child next to them. Once the ball reaches <strong>either</strong> end of the line, i.e. child 0 or child <code>n - 1</code>, the direction of passing is <strong>reversed</strong>.</p>
<p>Return the number of the child who receives the ball after <code>k</code> seconds.</p>
<p> </p>
<p><strongclass="example">Example 1:</strong></p>
<divclass="example-block">
<p><strong>Input:</strong><spanclass="example-io">n = 3, k = 5</span></p>
<p><strong>Note:</strong> This question is the same as <ahref="https://leetcode.com/problems/pass-the-pillow/description/"target="_blank"> 2582: Pass the Pillow.</a></p>