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:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.