Question 1 – Maximum Valid Subset of Points
You are given N integers representing point positions on a number line. You are also given: a window length L a modulo factor K You must select a subset of the given points such that: Every selected point gives the same remainder when divided by K. The difference between the maximum and minimum selected point is less than or equal to L. Find the maximum number of points that can be included in a valid subset. Input Format First line: N Second line: L Third line: K Fourth line: N space-separated integers (the point positions) Output Format Print the maximum size of a valid subset.
Question 2 – Minimum Interleaving Cost
You are given two sequences: A of length N B of length M You must interleave them into a single sequence of length N + M. The interleaving must preserve the original relative order of elements within A and within B. You are also given K magic separators. You may insert up to K magic separators anywhere in the interleaved sequence. The cost of an interleaved sequence is the sum of the absolute differences between every pair of adjacent elements. If a magic separator is placed between two adjacent elements, the cost between those two elements becomes 0, effectively splitting the sequence into two independent segments. Find the minimum possible total interleaving cost. Input Format First line: Integer N (length of sequence A) Second line: Integer M (length of sequence B) Third line: Integer K (maximum number of separators) Fourth line: N space-separated integers (A) Fifth line: M space-separated integers (B)
Question 3 – Number of Ways to Form N
You are given the numbers 1, 3, and 4. Your task is to construct a target number N by repeatedly choosing numbers from the set {1, 3, 4}. The following rules must be followed: You may use any of the numbers 1, 3, or 4 any number of times. The same number cannot be chosen consecutively. The order of the chosen numbers matters. Determine the total number of distinct ways to construct exactly N while satisfying the above condition. Input Format The first line contains a single integer N. Output Format Print a single integer representing the number of valid ways to construct N.