Company: Sap_20nov
Difficulty: medium
Path Through All Vertices in Increasing Order Problem Description You are given an undirected graph consisting of N vertices, numbered from 1 to N, and M edges. The graph is described by two arrays, A and B, both of length M. A pair (A[K], B[K]), for K from 0 to M-1, describes an edge between vertex A[K] and vertex B[K]. Your task is to check whether the given graph contains a path from vertex 1 to vertex N going through all of the vertices, one by one, in increasing order of their numbers. All connections on the path should be direct. Write a function: bool solution(int N, vector &A, vector &B); that, given an integer N and two arrays A and B of M integers each, returns true if there exists a path from vertex 1 to N going through all vertices, one by one, in increasing order, or false otherwise. Examples Example 1: Input: N = 4, A = [1, 2, 4, 3], B = [2, 3, 1, 1] Output: true Explanation: There is a path (1 → 2 → 3 → 4) using edges (1, 2), (2, 3) and (4, 3). Example 2: Input: N = 4, A