FastPrepUsers with a Short Sign-In Session
Problems/Users with a Short Sign-In Session

Users with a Short Sign-In Session

LinkedIn logoLinkedIn● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report directly specifies sorted signin/signout logs, a maximum time, and users with at least one session no longer than that bound, solved with a hash map. This contract matches at about 98%.

logs are globally sorted by increasing integer timestamp. Each entry is timestamp user SIGNIN or timestamp user SIGNOUT. Per user, sessions are well formed and non-overlapping.

Return sorted user ids that have at least one session with duration at most maxTime, where duration is signout timestamp minus its paired signin timestamp.

Function

usersWithShortSession(logs: String[], maxTime: int) → String[]

Examples

Example 1

logs = ["1 alice SIGNIN","2 bob SIGNIN","5 alice SIGNOUT","12 bob SIGNOUT"]maxTime = 5return = ["alice"]

Alice's duration is 4; Bob's is 10.

Example 2

logs = ["0 a SIGNIN","3 a SIGNOUT","10 a SIGNIN","20 a SIGNOUT"]maxTime = 3return = ["a"]

At least one qualifying session is sufficient.

Example 3

logs = ["1 z SIGNIN","9 z SIGNOUT"]maxTime = 7return = []

The only duration is 8.

Constraints

  • 0 <= logs.length <= 2 * 10^5.
  • Timestamps are strictly increasing nonnegative integers.
  • User ids have no spaces and each user's events alternate SIGNIN, SIGNOUT.

More LinkedIn problems

  • Explore an Unknown Grid and Find a PathONSITE INTERVIEW · Seen Nov 2026
  • Fire Station Response BillONSITE INTERVIEW · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public String[] usersWithShortSession(String[] logs, int maxTime) {
        // Write your solution here.
    }
}
Checking account…