Company: Citi Bank

Difficulty: medium

Problem Statement

There is a street described by a string S. Each character in S is one of the following: < denotes a car going to the left, > denotes a car going to the right, □ denotes a speed camera. Count the total number of times that cars pass by a speed camera. A car going to the left will pass every speed camera that is to the left of it, and similarly, a car going to the right will pass every speed camera to the right of it. Write a function: class Solution { public int solution(String S); } that, given a string S of length N, returns the total number of times that cars pass by a speed camera. Examples: Given S = '...>...□' , the function should return 3. The car will pass by three speed cameras to the right of it.

More Citi Bank OA questionsInterview experiences