FastPrepLongest All-Present Attendance Streak
Problems/Longest All-Present Attendance Streak

Longest All-Present Attendance Streak

Agoda logoAgoda● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report directly asks for the longest consecutive run of days on which all employees are present. The judged interface only makes the day-by-employee record shape explicit. The practice contract matches the report at about 98%.

You are given daily attendance records in attendance. Each string represents one day, each position represents the same employee across all days, 'Y' means present, and 'N' means absent.

Return the maximum number of consecutive days on which every employee was present. A day qualifies only when every character in its record is 'Y'. Return 0 when no day qualifies.

Function

longestAllPresentStreak(attendance: String[]) → int

Examples

Example 1

attendance = ["YYY","YYY","YNY","YYY"]return = 2

The first two days form the longest all-present streak.

Example 2

attendance = ["NN","YN","NY"]return = 0

Every day has at least one absence.

Example 3

attendance = ["Y","Y","Y"]return = 3

All three days qualify.

Constraints

  • 1 <= attendance.length <= 10^5.
  • 1 <= attendance[i].length <= 100.
  • All strings have the same length and contain only 'Y' and 'N'.

More Agoda problems

  • Sort Ones, Twos, and Threes In PlacePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Can Place FlowersPHONE SCREEN · Seen Nov 2026
  • Reverse Words in a StringPHONE SCREEN · Seen Nov 2026
All Agoda interview questionsSee Agoda hiring insights
Saved
class Solution {
    public int longestAllPresentStreak(String[] attendance) {
        // Write your solution here.
    }
}
Checking account…