- 2

Minimum edit array

Preferably with java or just the pseudocode is fine. Given the integer array a = [A1, A2, ···, an]. Your task is to do a series of operations on the array to make it a non descending array: you need to select a number x for each operation, and then move all elements equal to X in the array to the beginning or end of the array. For example, array a = [2, 1, 3, 1, 1, 3, 2] can be changed into a non descending array by the following two operations: 1. Move all elements equal to 1 to the beginning of the array to get [1, 1, 1, 2, 3, 3, 2] ; 2. Move all elements equal to 3 to the end of the array to get [1, 1, 1, 2, 2, 3, 3]. Please design an algorithm to calculate the minimum number of operations required to change a given array into a non descending array

28th Oct 2020, 3:26 PM
Quinna Jodanti
Quinna Jodanti - avatar
1 Resposta
+ 2
Don't post questions about your assignments and tasks. Please follow community rules. https://www.sololearn.com/discuss/1316935/?ref=app
28th Oct 2020, 4:27 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar