Please help !!! Digital structure problem. Preferably in C++ language.
Posted: Sun May 15, 2022 10:12 am
Please help !!! Digital structure problem. Preferably in
C++ language.
1. Reverse Array Queries For a given array of integers, perform operations on the array. Return the resulting array after all operations have been applied in the order given. Each operation contains two indices. Reverse the subarray between those zero-based indices, inclusive. Example arr = 19, 8, 7, 6, 5, 4, 3, 2, 1, OJ operations = [[0,9), (4,5), (3, 6), (2,7), (1,8], [0, 9]] Operatio n Left Το Reverse Right Result (0,9) 0 [9, 8, 7, 6, 5, 4, 3, 2, 1, 0 0] [0, 1, 2, 3, 4,5,6,7, 8,9) (4,5) [0, 1, 2, 3] [4, 5] [6, 7, 8, 9] [0, 1, 2, 3, 5,4,6,7,8, 9] (3,6) [0, 1, 2] [3, 5, 4, 6] [7, 8, 9] [0, 1, 2, 6, 4,5, 3, 7, 8, 9) (2,7) [0, 1] [2,6,4,5, 3,7] [8,9) [0, 1, 7, 3, 5, 4, 6, 2, 8, 9) (1,8) [ [O] [1,7,3,5, 4, 6, 2, 8] [9] [0, 8, 2, 6, 4,5, 3, 7, 1, 9] (0,9) 0 [0, 8, 2, 6, 4,5, 3, 7, 1, 0 9] [9, 1, 7, 3, 5, 4, 6, 2, 8, 0]
C++ language.
1. Reverse Array Queries For a given array of integers, perform operations on the array. Return the resulting array after all operations have been applied in the order given. Each operation contains two indices. Reverse the subarray between those zero-based indices, inclusive. Example arr = 19, 8, 7, 6, 5, 4, 3, 2, 1, OJ operations = [[0,9), (4,5), (3, 6), (2,7), (1,8], [0, 9]] Operatio n Left Το Reverse Right Result (0,9) 0 [9, 8, 7, 6, 5, 4, 3, 2, 1, 0 0] [0, 1, 2, 3, 4,5,6,7, 8,9) (4,5) [0, 1, 2, 3] [4, 5] [6, 7, 8, 9] [0, 1, 2, 3, 5,4,6,7,8, 9] (3,6) [0, 1, 2] [3, 5, 4, 6] [7, 8, 9] [0, 1, 2, 6, 4,5, 3, 7, 8, 9) (2,7) [0, 1] [2,6,4,5, 3,7] [8,9) [0, 1, 7, 3, 5, 4, 6, 2, 8, 9) (1,8) [ [O] [1,7,3,5, 4, 6, 2, 8] [9] [0, 8, 2, 6, 4,5, 3, 7, 1, 9] (0,9) 0 [0, 8, 2, 6, 4,5, 3, 7, 1, 0 9] [9, 1, 7, 3, 5, 4, 6, 2, 8, 0]