Three-Speaker Truth Consistency
Updated
Problem statement
Three speakers A, B, and C each make one statement. For this exercise, assume every option assigns a Boolean truth value to each speaker's statement.
An option is an integer mask from 0 through 7. Bit 0 gives A's assigned truth value, bit 1 gives B's, and bit 2 gives C's. A set bit means true; an unset bit means false.
The 3 x 8 matrix statements tells you whether each statement is true or false for each mask. The rows represent speakers A, B, C, in that order. statements[s][mask] is the truth value of speaker s’s statement under mask. These tables define the statements, so you do not need to parse sentences.
An option is consistent when both conditions hold:
- For every speaker
s, the supplied statement truthstatements[s][mask]equals bitsofmask. - Not all three statements are true, so
mask = 7is excluded. All three statements may be false.
Given statements and the ordered array options, return the zero-based index of the first consistent option. Return -1 if no offered option is consistent. Duplicate options are allowed and keep their original positions.
Function
firstConsistentOption(statements: int[][], options: int[]) → intExamples
Example 1
statements = [[0,0,1,1,0,0,1,1],[0,1,0,1,0,1,0,1],[0,0,0,0,0,0,0,0]]options = [7,2,3,0]return = 2The supplied tables require A and B to have the same truth value, while C is false. Masks 3 and 0 are consistent. Mask 3 appears first in the offered list, at index 2.
Example 2
statements = [[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1]]options = [7,6,3]return = -1Only mask 7 agrees with the three constant-true statements. It is excluded because all three truth bits are 1, so no offered option qualifies.
Example 3
statements = [[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0]]options = [0]return = 0Mask 0 makes all three statements false. This satisfies the requirement that not all statements are true, so the option at index 0 qualifies.
Constraints
statements.length = 3and every row has length8.- Every table entry is
0or1. 0 <= options.length <= 1000.0 <= options[i] <= 7.
More Susquehanna International Group (SIG) Online Assessment questions
- Centered Block Placement QueriesOA · Seen Dec 2026
- Catch Fish with Reusable BaitsOA · Seen Nov 2026
- Bold Play to Reach a GoalOA · Seen Nov 2026
- Cats, Truth and Who Has MoreOA · Seen Nov 2026
- Counting Cows by Their LegsOA · Seen Nov 2026
- Enough Muffins for the LineOA · Seen Nov 2026
- Expected Consecutive Pairs Among Chosen NumbersOA · Seen Nov 2026
- Four-by-Four Boundary GridOA · Seen Nov 2026
- Frog Paths Without Long RunsOA · Seen Nov 2026
- Higher Roll, or Lose the SumOA · Seen Nov 2026
Similar questions at other companies
- Operations to Reduce a Binary String Value to ZeroMarshall Wace · OAMarshall Wace interview questions
- Repeated Mirror XORMathWorks · OAMathWorks interview questions
- Competitive ForagingAkuna Capital · OAAkuna Capital interview questions
- Decrement a Binary Number and Count Its OnesZipRecruiter · OAZipRecruiter interview questions
- Number of Steps to Reduce a Binary Number to OneDeloitte · OADeloitte interview questions
- XOR Pseudorandom SequenceBaseten · PHONE SCREENBaseten interview questions
- CPU Register Bitwise OperationsHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
- Set and Clear BitsAMD · PHONE SCREENAMD interview questions
- Clocked Counter with Reset and EnableXilinx · PHONE SCREENXilinx interview questions
- Out-of-Order TLV File ReassemblyApplied Intuition · PHONE SCREENApplied Intuition interview questions