Two codes were given! We have to do this on code chef! Following were the two programs :- There are N boxes and N balls. Each of the box and the ball has a number printed on it within the range 0 to (N-1). These balls are randomly put into the boxes one ball in each box in no particular order. There is one extra box with no number printed on it. Moving one ball at a time, you are expected to correct the order of these balls such that ith ball goes in ith box. you can use the extra empty box that is provided. When you pick any ball, it has to go in some box before you pick other ball.
Input
An integer T denoting the number of test cases.
For each test case there are 2 lines.
The first line contains a single integer N where N denotes the number of balls.
The second line contains N integers K0 to KN-1 where Ki represents the number marked on the ball in the ith box in the initial configuration.
Output
For each test output a single integer M, where M is the number of ball moves required to arrange all the balls to their proper location.
Example
Input: 2 3 1 0 2 4 2 1 3 0
Output: 3 4
Given a sequence of n distinct elements, convert the given sequence to a form where all elements are in range from 0 to n-1. The order of elements is same, i.e., 0 is placed in place of smallest element, 1 is placed for second smallest element, n-1 is placed for largest element.
Input First line contains the number of elements in the sequence i.e. n. Second line contains n space separated elements that makes the sequence.
OUTPUT Print n space separated ranks for the elements of the sequence.
Test case 1: Input: 3 10 40 25 Output: 0 2 1
Test case 2: Input: 6 5 11 40 21 5 7 Output: 0 2 4 3 0 1
It was Java based.
The following metrics were computed from 1 interview experience for the Media.net Applications Developer Engineer role in Ulhasnagar, India.
Media.net's interview process for their Applications Developer Engineer roles in Ulhasnagar, India is extremely selective, failing the vast majority of engineers.
Candidates reported having very negative feelings for Media.net's Applications Developer Engineer interview process in Ulhasnagar, India.