you give 2D integer array order ordersi pricei amounti orderTypei denote amounti order place type orderTypei price pricei the orderTypei is0 batch buy order or1 batch sell ordersnote ordersi represent batch amounti independent order price order type all order represent ordersi place order represent ordersi1 valid iThere backlog consist order execute the backlog initially when order place follow happensIf order buy order look sell order small price backlog if sell order price small equal current buy order price match execute sell order remove backlog Else buy order add backlogvice versa order sell order look buy order large price backlog if buy order price large equal current sell order price match execute buy order remove backlog else sell order add backlogReturn total order backlog place order input since number large return modulo 109 7 Example 1input order 1050152125113040output 6explanation here happen order 5 order type buy price 10 place there sell order 5 order add backlog 2 order type sell price 15 place there buy order price large equal 15 2 order add backlog 1 order type sell price 25 place there buy order price large equal 25 backlog order add backlog 4 order type buy price 30 place the 2 order match 2 sell order price 15 2 sell order remove backlog the 3rd order match sell order price 25 sell order remove backlog then sell order backlog 4th order add backlogfinally backlog 5 buy order price 10 1 buy order price 30 so total number order backlog 6Example 2input order 710000000001153059999999950511output 999999984explanation here happen order 109 order type sell price 7 place there buy order 109 order add backlog 3 order type buy price 15 place they match 3 sell order price 7 3 sell order remove backlog 999999995 order type buy price 5 place the price sell order 7 999999995 order add backlog 1 order type sell price 5 place it match buy order high price 5 buy order remove backlogfinally backlog 10000000003 sell order price 7 9999999951 buy order price 5 so total number order 1999999991 equal 999999984 109 7 Constraints1 orderslength 105ordersilength 31 pricei amounti 109ordertypei 0 1