• + 0 comments

    One line solution :)

    return k < n/2 ? (2*k + 1) : 2*(n - k - 1)