0
Why this code is not works?
This code gives run time error. why? https://code.sololearn.com/c2PU3O85O5hI
6 odpowiedzi
0
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ I used and i don't give run time error. What is the input of the code?
0
Benjamin Salas
You will be give three integer as main input. t,n,x and you will give n number of numbers which means the n length array of integers. This code is work if t=1 .
But it is not work for higher value of t.
Sample input:
1
3 2
1 2 3
Output :
2 1
But this code is not working when t>1
Like:
2
5 100
1 2 3 4 5
4 1
2 2 6 6
output :
1 0
2 0
0
For example if you put 2 what is the output? Explain to me the logic
0
Benjamin Salas
It is a one of the problems in the codechef September long challenge.
link:https://www.codechef.com/problems/PALINT
Logic is make an array of n integers to maximum number of equal integers in minimum number of xor operations.
Logic in my code is :
1)Take an array of n integers.
2)sort it .
3)And for each element in the array make these actions,
* first count the appearances of an element in the array.
* then , find the value ( element ^x) in the array using binary search.
* then, start counting the appearances of (element ^x) from that position to 0 and position to n in the array.
ex:
3 2 // n=3 x=2
1 2 3 // array
xor 2 with third element.
[1 2 1] -> 2 elements.
0
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ can you resolved the problem?
0
Benjamin Salas no. I did not resolved.