Intersection of Sorted Arrays Problem

Intersection of Sorted Arrays Problem — ExecCode School DSA Practice

Solve the Intersection of Sorted Arrays problem on ExecCode. Free online school DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given an array of N integers, check whether the array is sorted (non-decreasing) and print the result as shown in the examples. Your task is to understand the rule and print the correct answer. You are working on Intersection of Sorted Arrays.

Examples

Input 5 3 1 2 3 4 5 2 4 6; Output 2 4. Input 3 3 1 2 3 4 5 6; Output

Constraints

1 <= n <= 10^5

Practice Intersection of Sorted Arrays free on ExecCode. Browse DSA problems, topic map, and placement guides.