• + 0 comments
    function processData(input) {
    input = input.split(/\r?\n/)
    let array = input[1].split(' ').map((val)=>{
        return Number(val)
    })
    input.shift()
    input.shift()
    // let quariSize = Number(input[0].split(' ')[1])
    //     for(let i = 0 ; i<quariSize ; i++){
            
    //     }
    let newarr=[]
     input= input.map((val)=>{
        val = val.split(" ")
        let d = val.map(value => Number(value))
        newarr.push(d)
    })
    //now newarr is our quaries
    for(let i = 0;i<newarr.length;i++){
        let choice = newarr[i][0]
        let lb = newarr[i][1]-1
        let ub = newarr[i][2]
        let temparr = array.splice(lb,ub-lb)
        if(choice == 2){
            array = array.concat(temparr)
        }
        else{
           array = temparr.concat(array)
        }
    }
    console.log(Math.abs(array[array.length-1]-array[0]))
    let str = ''
    for(let i of array){
        str+= i+' '
    }
    console.log(str)
    }
    

    7 test case doesnt pass due to time limit exceeded