Statistics

Problem Statement for "CountryGroup"

Problem Statement

Some people are sitting in a row. Each person came here from some country. You have a theory that people from the same country are all sitting together. You decided to test this theory. You asked each person the same question: "How many people from your country (including you) are here?"

You are given a int[] a containing their answers. The answers are given in the order in which the people sit in the row. (Note that some of the answers may be incorrect. See the examples for clarification.)

If all the answers are consistent with your theory, return the number of different countries that are present. (Given that all answers are consistent with the theory, the number of countries can always be uniquely determined.) Otherwise, return -1.

Definition

Class:
CountryGroup
Method:
solve
Parameters:
int[]
Returns:
int
Method signature:
int solve(int[] a)
(be sure your method is public)

Constraints

  • The number of elements in a will be between 1 and 100, inclusive.
  • All elements of a will be between 1 and 100, inclusive.

Examples

  1. {2,2,3,3,3}

    Returns: 2

    These answers are consistent with your theory. The first two people are from one country, the other three are from a different country. Thus, there are two countries and the correct return value is 2.

  2. {1,1,1,1,1}

    Returns: 5

    Here, each person comes from a different country.

  3. {3,3}

    Returns: -1

    These answers do not correspond to your theory. In particular, they are not even correct: there are only two people but each of them claims that there are three people from their country.

  4. {4,4,4,4,1,1,2,2,3,3,3}

    Returns: 5

  5. {2,1,2,2,1,2}

    Returns: -1

    These answers do not correspond to your theory. It is possible that these are people from four different countries, but even if that were the case, we can tell that people from some countries are not sitting together. For example, consider the leftmost person. According to her answer, there are two people from her country. However, the person sitting next to her cannot be from the same country.

  6. {100}

    Returns: -1

  7. {1}

    Returns: 1

  8. {2}

    Returns: -1

  9. {2,2,2,2,4,4,4,4}

    Returns: 3

  10. {5,4,3,2,1}

    Returns: -1

  11. {1,2,2,1}

    Returns: 3

  12. {3,1,3,3}

    Returns: -1

  13. {7,7,7,7,7,7,7,7}

    Returns: -1

  14. {1,2,2,1,1,1,2,2,2,2,1,1,1,1,2,2,1,1,3,3,3,1,1,1,2,2,3,3,3,1,1,1,1,1}

    Returns: 25

  15. {3,2,2}

    Returns: -1

  16. {1,2,3,4,5}

    Returns: -1

  17. {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}

    Returns: 100

  18. {10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10}

    Returns: 10

  19. {99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99}

    Returns: -1

  20. {49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,49,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51,51}

    Returns: 2

  21. {2,2,4,4,4,4,4,4,4,4,3,3,3,2,2,1,4,4,4,4,4,4,4,4,1,2,2,3,3,3,4,4,4,4,1,5,5,5,5,5,4,4,4,4,2,2,1,3,3,3,2,2,5,5,5,5,5,4,4,4,4,3,3,3,4,4,4,4,5,5,5,5,5,2,2,5,5,5,5,5,5,5,5,5,5,3,3,3,2,2,3,3,3,4,4,4,4}

    Returns: 31

  22. {5,5,5,5,5,1,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4,4,3,3,3,3,3,3,1,1,1,5,5,5,5,5,5,5,5,5,5,4,4,4,4}

    Returns: 31

  37. {2,2,2,2,5,5,5,5,5,3,3,3,3,3,3,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,1,4,4,4,4,5,5,5,5,5,1,1,4,4,4,4,4,4,4,4,5,5,5,5,5,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,3,3,3,5,5,5,5,5,4,4,4,4,5,5,5,5,5,1,1,5,5,5,5,5}

    Returns: 30

  38. {5,5,5,5,5,4,4,4,4,5,5,5,5,5,5,5,5,5,5,2,2,3,3,3,1,3,3,3,2,2,1,5,5,5,5,5,2,2,3,3,3,2,2,2,2,5,5,5,5,5,5,5,5,5,5,2,2,3,3,3,5,5,5,5,5,1,2,2,1,5,5,5,5,5,2,2,1,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,1}

    Returns: 32

  39. {4,4,4,4,2,2,1,4,4,4,4,1,1,1,1,2,2,1,4,4,4,4,1,4,4,4,4,2,2,5,5,5,5,5,1,2,2,2,2,5,5,5,5,5,2,2,4,4,4,4,4,4,4,4,3,3,3,1,3,3,3,5,5,5,5,5,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,4,4,4,4,1,5,5,5,5,5,4,4,4,4,4,4,4,4}

    Returns: 37

  40. {3,3,3,3,3,3,3,3,3,4,4,4,4,1,3,3,3,4,4,4,4,4,4,4,4,2,2,3,3,3,4,4,4,4,5,5,5,5,5,1,4,4,4,4,1,3,3,3,1,2,2,4,4,4,4,1,3,3,3,3,3,3,3,3,3,5,5,5,5,5,5,5,5,5,5,2,2,1,3,3,3,1,1,1,3,3,3,3,3,3,4,4,4,4,1,3,3,3,2,2}

    Returns: 37

  41. {5,5,5,5,5,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,10,10,10,10,10,10,10,10,10,10,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,6,6,6,6,6,6,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16}

    Returns: 7

  42. {3,3,3,1,9,9,9,9,9,9,9,9,9,1,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,5,7,7,7,7,7,7,7,1,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,2,2}

    Returns: 12

  43. {1,11,11,11,11,11,11,11,11,11,11,11,1,5,5,5,5,5,11,11,11,11,11,11,11,11,11,11,11,3,3,3,4,4,4,4,5,5,5,5,5,2,2,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,41,6,6,6,6,6,6,1}

    Returns: 12

  44. {12,12,12,12,12,12,12,12,12,12,12,12,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,2,2,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,1,5,5,5,5,5,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31}

    Returns: 7

  45. {7,7,7,7,7,7,7,5,5,5,5,5,10,10,10,10,10,10,10,10,10,10,1,1,7,7,7,7,7,7,7,3,3,3,1,7,7,7,7,7,7,7,5,5,5,5,5,2,2,8,8,8,8,8,8,8,8,5,5,5,5,5}

    Returns: 13

  46. {47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,5,5,5,5,5,3,3,3,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,2,2}

    Returns: 6

  47. {2,2,9,9,9,9,9,9,9,9,9,4,4,4,4,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,2,2,5,5,5,5,5,6,6,6,6,6,6,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22}

    Returns: 8

  48. {25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11,11,11,11,11,11,11,11,2,2,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,8,8,8,8,8,8,8,8}

    Returns: 6

  49. {4,4,4,4,1,1,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,1,12,12,12,12,12,12,12,12,12,12,12,12,3,3,3,5,5,5,5,5,6,6,6,6,6,6,2,2,2,2}

    Returns: 11

  50. {9,9,9,9,9,9,9,9,9,1,2,2,1,2,2,2,2,4,4,4,4,2,2,6,6,6,6,6,6,6,6,6,6,6,6,1,1,5,5,5,5,5,1,5,5,5,5,5,1,1}

    Returns: 17

  51. {4,4,4,4,4,4,4,4,10,10,10,10,10,10,10,10,10,10,3,3,3,1,8,8,8,8,8,8,8,8,4,4,4,4,10,10,10,10,10,10,10,10,10,10,5,5,5,5,5,1}

    Returns: 10

  52. {2,2,5,5,5,5,5,2,2,1,12,12,12,12,12,12,12,12,12,12,12,12,6,6,6,6,6,6,4,4,4,4,2,2,5,5,5,5,5,2,2,4,4,4,4,2,2,1,3,3,3,3,3,3,1,3,3,3,4,4,4,4}

    Returns: 18

  53. {3,3,3,6,6,6,6,6,6,6,6,6,6,6,6,9,9,9,9,9,9,9,9,9,1,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,2,2,7,7,7,7,7,7,7,5,5,5,5,5,3,3,3,3,3,3,8,8,8,8,8,8,8,8,6,6,6,6,6,6,4,4,4,4,3,3,3}

    Returns: 15

  54. {1,8,8,8,8,8,8,8,8,12,12,12,12,12,12,12,12,12,12,12,12,3,3,3,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,5,5,5,5,5,7,7,7,7,7,7,7,4,4,4,4,3,3,3,3,3,3,1,5,5,5,5,5,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15}

    Returns: 13

  55. {3,3,3,1,2,2,5,5,5,5,5,6,6,6,6,6,6,5,5,5,5,5,3,3,3,5,5,5,5,5,1,1,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,2,2,4,4,4,4,1}

    Returns: 14

  56. {5,5,5,5,5,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,2,2,14,14,14,14,14,14,14,14,14,14,14,14,14,14,5,5,5,5,5,2,2,2,2,3,3,3,13,13,13,13,13,13,13,13,13,13,13,13,13}

    Returns: 9

  57. {3,3,3,3,3,3,1,1,1,4,4,4,4,1,2,2,1,6,6,6,6,6,6,7,7,7,7,7,7,7,1,2,2,5,5,5,5,5,10,10,10,10,10,10,10,10,10,10,1,2,2,2,2}

    Returns: 18

  58. {1,1,12,12,12,12,12,12,12,12,12,12,12,12,5,5,5,5,5,7,7,7,7,7,7,7,7,7,7,7,7,7,7,4,4,4,4,7,7,7,7,7,7,7,4,4,4,4,2,1,13,13,13,13,13,13,13,13,13,13,13,13,13,3,3,3,5,5,5,5,5}

    Returns: -1

  59. {8,8,8,8,8,8,8,8,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,13,13,13,13,13,13,13,13,13,13,13,13,13,2,2,13,13,13,13,13,13,13,13,13,13,13,13,13,4,4,4,4,7,7,7,7,7,7,7,13,13,13,13,13,13,13,13,13,13,13,13,13}

    Returns: 8

  60. {3,3,3,9,9,9,9,9,9,9,9,9,1,2,2,4,4,4,4,2,2,6,6,6,6,6,6,4,4,4,4,6,6,6,6,6,6,4,4,4,4,5,5,5,5,5,1,2,2,4,4,4,4,4,4,4,4,7,7,7,7,7,7,7,4,4,4,4,5,5,5,5,5,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,2,2}

    Returns: 20

  61. {100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100}

    Returns: -1

  62. {100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100}

    Returns: 1

  63. {4, 4, 4, 4, 1, 1, 2, 2, 3, 3, 3 }

    Returns: 5

  64. {2, 1 }

    Returns: -1

  65. {2, 2, 1, 1, 3, 3, 3, 2, 2 }

    Returns: 5

  66. {2, 1, 1 }

    Returns: -1

  67. {3, 3, 3, 1, 3, 3, 3 }

    Returns: 3

  68. {3, 1, 3 }

    Returns: -1

  69. {2, 2, 2, 2 }

    Returns: 2

  70. {3, 3 }

    Returns: -1

  71. {1, 2 }

    Returns: -1

  72. {1, 2, 2, 2 }

    Returns: -1

  73. {3, 3, 3, 3, 3, 3 }

    Returns: 2

  74. {2, 2, 2 }

    Returns: -1

  75. {2 }

    Returns: -1

  76. {2, 2, 3, 3, 3 }

    Returns: 2

  77. {4, 3, 4, 4 }

    Returns: -1

  78. {2, 1, 2 }

    Returns: -1

  79. {2, 3 }

    Returns: -1

  80. {4, 1, 1, 4, 1, 1 }

    Returns: -1

  81. {4, 4, 4, 3 }

    Returns: -1

  82. {2, 1, 2, 2, 1, 1 }

    Returns: -1

  83. {3, 1, 2, 3, 2, 3, 1 }

    Returns: -1

  84. {2, 2, 1, 2, 2 }

    Returns: 3

  85. {1 }

    Returns: 1

  86. {1, 2, 2, 3, 2, 3, 3, 2 }

    Returns: -1

  87. {1, 2, 2, 1 }

    Returns: 3

  88. {2, 1, 2, 1 }

    Returns: -1


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: