FastPrepSimulate a Deterministic Finite Automaton
Problems/Simulate a Deterministic Finite Automaton

Simulate a Deterministic Finite Automaton

Point72 logoPoint72● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Point72 online assessment. The report describes a simulator for a deterministic finite automaton, over a string of a and b, with a state-transition table and acceptance by final state. It does not give the exact table format, how states are numbered, the rule for empty input, or the limits. Our version keeps the reported state changes and the accept or reject decision. It is about 88% the same as the reported question.

Simulate a deterministic finite automaton and return whether it accepts input.

The automaton has states numbered from 0 through transitions.length - 1. For every state s:

  • transitions[s][0] is the next state after reading a.
  • transitions[s][1] is the next state after reading b.

Begin at startState and process the characters of input from left to right. Return true if the state reached after the entire string belongs to acceptingStates; otherwise, return false. An empty input performs no transition, so acceptance depends on whether startState is accepting.

Function

acceptsDFA(input: String, transitions: int[][], startState: int, acceptingStates: int[]) → boolean

Examples

Example 1

input = "abba"transitions = [[1,0],[1,0]]startState = 0acceptingStates = [1]return = true

The visited states are 0 -> 1 -> 0 -> 0 -> 1. The final state 1 is accepting.

Example 2

input = "bbb"transitions = [[1,0],[1,0]]startState = 0acceptingStates = [1]return = false

Every b transition keeps the automaton at state 0, which is not accepting.

Example 3

input = ""transitions = [[0,0]]startState = 0acceptingStates = [0]return = true

The empty input leaves the automaton at its accepting start state.

Constraints

  • 1 <= transitions.length <= 100000
  • transitions[s].length == 2 for every state s.
  • Every transition destination, startState, and accepting state is between 0 and transitions.length - 1.
  • 0 <= input.length <= 100000
  • input contains only a and b.
  • acceptingStates contains distinct state numbers.

More Point72 interview questions

  • Maximize Array Beauty After DeletionsOA · Seen Aug 2026
  • Initial Public OfferingOA · Seen Jul 2026
  • Test the HypothesisOA · Seen Jul 2026
  • Get Triplet CountOA · Seen Jul 2026
  • Internet Service Provider Monthly ReportOA · Seen Jul 2026
  • Server SelectionOA · Seen Jul 2026
  • Lexicographically Smallest String After Substring OperationOA · Seen May 2026
  • Best Time to Buy and Sell Stock IIPHONE SCREEN · Seen Aug 2026
  • Find Minimum in a Rotated Sorted ArrayPHONE SCREEN · Seen Aug 2026
  • Generate an Optimal Portfolio Trading ReportPHONE SCREEN · Seen Apr 2026

Similar questions at other companies

  • Collect Letters Along a Unique Grid PathApple · OAApple interview questions
  • Repair One Movement InstructionOpenAI · OAOpenAI interview questions
  • Count Straight-Line Word Occurrences in a GridOptiver · OAOptiver interview questions
  • Count Straight-Line Word Occurrences in a GridVisa · OAVisa interview questions
  • Flip Rows and Columns, Count ZerosNutanix · OANutanix interview questions
  • Hidden ArtifactsIMC Trading · OAIMC Trading interview questions
  • Excel Training Data and Model Response AuditMicrosoft · PHONE SCREENMicrosoft interview questions
  • BitFont Part 1 - Render a CharacterStripe · ONSITE INTERVIEWStripe interview questions
  • Alphabet Board PathZillow · ONSITE INTERVIEWZillow interview questions
  • Cyclic Fuel Command SimulationWaymo · ONSITE INTERVIEWWaymo interview questions
All Point72 interview questionsSee Point72 hiring insights
Saved
class Solution {
    public boolean acceptsDFA(String input, int[][] transitions, int startState, int[] acceptingStates) {
      // write your code here
    }
}
Checking account…