Given two integers N and X. Then the duty is to return YES or NO by checking whether or not there exists a subarray in any permutation of size N such that it accommodates a subarray, the place A*B is the same as the X. Right here A and B denote the variety of components in subarray and the primary ingredient of sorted subarray respectively.
Examples:
Enter: N = 5, X = 3
Output: YES
Clarification: Thought of the permutation is: {5, 2, 1, 3, 4}. Take the subarray {A_{4}. . . .A_{4}} = { 3 }. Then A = 1 (As just one ingredient is there), B = 3 (If the subarray is sorted then first ingredient of that subarray might be 3). So, A * B = 1 * 3 = 3, Which is the same as Y. Due to this fact, output is YES.Enter: N = 7, X = 56
Output: NO
Clarification: It may be verified that no permutation of size N exists such that, It provides worth of A * B as 56. Due to this fact, output is NO.
Strategy: To resolve the issue observe the under thought:
The issue relies on Grasping logic and statement based mostly. It may be solved by implementing these observations by implementing them in a code. The statement is, there’ll certainly exist a subarray if the situation (X % i == 0 && (X / i) ≥ 1 && (( X / i) ≤ N – i + 1) efficiently meet, the place i is the present ingredient.
Under are the steps for the above strategy:
 Create a Boolean Flag and mark it as False initially.
 Run a for loop from i = 1 to i ≤ N and observe the belowmentioned steps underneath the scope of the loop:
 If (X % i == 0 && (X / i) ≥ 1 && (( X / i) ≤ N – i + 1) is true then mark the flag as true and break the loop.
 Test if the flag is true, print YES else, print NO.
Under is the code to implement the strategy:
Java

Time Complexity: O(N)
Auxiliary House: O(1), As no further area is used.