Symmetric Round-Trip Itinerary

Company: Makemytrip_3aug

Difficulty: medium

Problem Statement

Symmetric Round-Trip Itinerary Problem Description An airline planner has an itinerary string representing a sequence of airport codes joined by hyphens, e.g. "SFO-LAX-SEA-LAX-SFO-BOS" A subsequence of this itinerary is obtained by deleting zero or more airport codes without changing the order of the remaining codes. Find the length of the longest subsequence of airport codes that reads the same forwards and backwards (i.e., a palindromic subsequence), so the planner can identify the largest symmetric round-trip segment. Examples Example 1: Input: itinerary = "NYC-LAX-CHI-LAX-NYC-BOS" Output: 5 Explanation: One palindromic subsequence is ["NYC", "LAX", "CHI", "LAX", "NYC"]. Example 2: Input: itinerary = "HND-POR-STU-PQR-HND" Output: 5 Constraints 1 ≤ number of codes ≤ 4000 Codes are fixed-length (3 uppercase letters) Input should be string Output should be integer