/**
 * Given two lists, return a list of the positions of the common elements.
 * Negative indexing should also be considered.
 *
 * Example:
 * getIntersectionPositions(listOf(1, 3, 4, 7, 9, 12), listOf(5, 4, 3, 2, 1)) => listOf(0, -3, 5)
 *
 * @param lis1 A list of elements.
 * @param lis2 A list of elements.
 * @return A list of positions (indexes) of the common elements between both lists.
 */
fun getIntersectionPositions(lis1: List<Int>, lis2: List<Int>): List<Int> {

    val commonPositions = mutableListOf<Int>()

    // Iterate through each element in lis1
    for (i in lis1.indices) {
        // Check if the current element exists in lis2
        if (lis1[i] in lis2) {
            // Append the position/index of the common element to the list
            commonPositions.add(i)
        } else if (lis1.getOrNull(lis1.size - 1 - i) in lis2) {
            // Append the negative position/index of the common element to the list
            commonPositions.add(-(i + 1))
        }
    }

    return commonPositions
}
/**
 * Given two lists, return a list of the positions of the common elements.
 * Negative indexing should also be considered.
 *
 * Example:
 * getIntersectionPositions(listOf(1, 3, 4, 7, 9, 12), listOf(5, 4, 3, 2, 1)) => listOf(0, -3, 5)
 *
 * @param lis1 A list of elements.
 * @param lis2 A list of elements.
 * @return A list of positions (indexes) of the common elements between both lists.
 */
fun getIntersectionPositions(lis1: List<Int>, lis2: List<Int>): List<Int> {
/**
 * Given two lists, return a list of the positions of the common elements.
 * Negative indexing should also be considered.
 *
 * Example:
 * getIntersectionPositions(listOf(1, 3, 4, 7, 9, 12), listOf(5, 4, 3, 2, 1)) => listOf(0, -3, 5)
 *
 * @param lis1 A list of elements.
 * @param lis2 A list of elements.
 * @return A list of positions (indexes) of the common elements between both lists.
 */
fun getIntersectionPositions(lis1: List<Int>, lis2: List<Int>): List<Int> {

    val commonPositions = mutableListOf<Int>()

    // Iterate through each element in lis1
    for (i in lis1.indices) {
        // Check if the current element exists in lis2
        if (lis1[i] in lis2) {
            // Append the position/index of the common element to the list
            commonPositions.add(i)
        } else if (lis1.getOrNull(lis1.size - 1 - i) in lis2) {
            // Append the negative position/index of the common element to the list
            commonPositions.add(-(i + 1))
        }
    }

    return commonPositions
}