One Two Three
All submissions for this problem are available.
You are given a sequence made up of 1,2&3 , of length up to 1000. Find the minimum number of exchanges 'X' to put the sequence in sorted order.
First line contains the number of test cases T.
Following T lines has a number N, which denotes the size of the sequence S.
Following N integers are the values of the sequence S.
N1 S0 S1... SN1
N2 S0 S1....SN2
For each test case, output the value X.
Input: 2 6 1 2 3 1 2 3 6 1 1 2 3 2 3 Output: 2 1
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.