BackmediumArrays arrays medium

Longest Holiday Free Subsequence Solution

Problem Statement

Given an array of strings representing days of the week, determine the length of the longest subsequence that does not contain any holidays.

Example 1
Input
["Mon","Tue","Wed","Thu","Fri","Sat","Sun","Mon","Tue","Wed"]
Output
2

Explanation: The longest subsequence without consecutive holidays (considering the problem description's holidays) is indeed ['Mon', 'Tue'], ['Tue', 'Thu'] or other similar non-holiday days, which has a length of 2.

Constraints

  • You can only sell on weekdays. You must not sell for two consecutive days if today is the same day as yesterday.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free