Company: Citi Bank_28thjune

Difficulty: medium

Problem Statement

A street is described by a string S, where every character is one of the following: < denotes a car going to the left, > denotes a car going to the right, □ denotes a speed camera. Work out the total number of times cars pass a speed camera anywhere on the street. A car heading left passes every camera positioned to its left, and a car heading right passes every camera positioned to its right. 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_28thjune OA questionsInterview experiences