These are the questions from Agoda's online assessment for intern role.
Description:
You are given a permutation arr of length n (containing integers from 1 to n) and an integer k.
A subarray is considered valid if you can pick exactly k elements from it such that, after reordering, they form k consecutive integers.
Return the minimum length of any valid subarray.
Example:
Input:
arr = [10, 1, 6, 8, 7, 2, 5, 9, 3, 4]
k = 5
Output:
6
Description:
Given a string s, return the total number of palindromic substrings in it.
A substring is a contiguous sequence of characters.
Example:
Input:
s = "abcbd"
Output:
6
Description:
You are given an integer array arr and two integers min_price and max_price.
Return the number of subarrays such that:
Example:
Input:
arr = [1, 5, 6, 5]
min_price = 5
max_price = 6
Output:
3