FastPrepTwo Tribes from Taller-Person Counts
Problems/Two Tribes from Taller-Person Counts

Two Tribes from Taller-Person Counts

Intuit logoIntuit● MediumFULLTIMEOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The core counting task matches the report at about 85%. The report omits precise tribe-label, empty-group, height-order, and answer-format conventions; those rules and numerical bounds are specified here.

There are n = a.length distinct people. Person i reports that exactly a[i] people in their own tribe are taller than them. Assign every person to one of two tribes so that all reports can be true.

For this exercise, use the following conventions:

  • The tribes are named A and B. An assignment changes when any particular person moves to the other named tribe. Swapping the two tribes therefore counts as a different assignment.
  • Either tribe may be empty.
  • Everyone has a different height. Heights are not given, and there are no other rules about their order. A tribe containing s people is valid exactly when its reported counts contain each integer from 0 through s - 1 once.
  • Count only assignments of people to tribes. Do not count different possible heights or different ways the two tribes could be arranged together by height.

Return the exact number of valid assignments as a 64-bit integer, without taking a modulus. Return 0 when no assignment satisfies the reports.

Function

countTribeAssignments(a: int[]) → long

Examples

Example 1

a = [0,0,1]return = 4

Person 2, whose report is 1, must share a tribe with exactly one of persons 0 and 1. There are two choices of that partner and two choices of which named tribe receives the pair, giving 2 × 2 = 4 assignments.

Example 2

a = [0,0,1,1]return = 4

Each tribe must contain one person reporting 0 and one reporting 1. Choose the report-0 person for tribe A in two ways and the report-1 person for A in two ways. The other two people join B, giving 4 assignments.

Constraints

  • For this exercise, assume 1 <= a.length <= 120.
  • For this exercise, assume every reported count satisfies 0 <= a[i] < a.length.
  • Repeated reports are allowed, and the input is not guaranteed to admit a valid assignment.
  • The exact answer is at most 2^60, so it fits in a signed 64-bit integer.

More Intuit Online Assessment questions

  • Employee Promotion OpportunitiesOA · Seen Oct 2026
  • Next Pascal Row CoefficientOA · Seen Oct 2026
  • Parse Router LogsOA · Seen Oct 2026
  • Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
  • Maximum Square-Free DivisorOA · Seen Oct 2026
  • Shortest Path from an Encoded GraphOA · Seen Sep 2026
  • Oldest and Youngest EmployeesOA · Seen Sep 2026
  • Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
  • Submask Sum QueriesOA · Seen Sep 2026
  • Alien DictionaryOA · Seen Sep 2026

Similar questions at other companies

  • Count Overlapping Square PairsRamp · OARamp interview questions
  • Find Valid SET Card TriplesSnowflake · OA · PHONE SCREENSnowflake interview questions
  • Count One-Swap Number PairsCapital One · OACapital One interview questions
  • Get Triplet CountIBM · OAIBM interview questions
  • Count Reverse-Digit PairsVisa · OAVisa interview questions
  • Count 2x2 Submatrices by Black CellsTikTok · OATikTok interview questions
  • Get Triplet CountPoint72 · OAPoint72 interview questions
  • Cheating CodemakerJane Street · OAJane Street interview questions
  • Counting Triplets Divisible by DAT&T · OAAT&T interview questions
  • Minimize Distinct Item Types After RemovalsRoblox · OARoblox interview questions

Interview reports that mention this question

  • Intuit OA: What It Tests (2026)

Intuit interview experiences

  • Intuit Software Engineering Intern - Full Stack OA Format
All Intuit interview questionsSee Intuit hiring insights
Saved
class Solution {
    public long countTribeAssignments(int[] a) {
        // Implement this method.
    }
}
Checking account…