dimanche 29 mars 2015

Define a Dual array to be an array where every value occurs exactly twice




  1. Define a Dual array to be an array where every value occurs exactly twice.


For example, {1, 2, 1, 3, 3, 2} is a dual array.


The following arrays are not Dual arrays {2, 5, 2, 5, 5} (5 occurs three times instead of two times) {3, 1, 1, 2, 2} (3 occurs once instead of two times)


Write a function named isDual that returns 1 if its array argument is a Dual array. Otherwise it returns 0.


If you are programming in Java or C#, the function signature is int isDual (int[ ] a)




Aucun commentaire:

Enregistrer un commentaire