1.

You are given two strings \(A\) and \(B\) that are made of lowercase English alphabets. Find the number of different pairs \(((i,\ j),\ (k,\ l))\)such that the substrings\(A[i...j]\) and \(B[k...l]\) are equal and the value of \(j-i+1\)is minimum.

Input format

  • The first line consists of a string denoting \(A\).
  • The second line consists of a string denoting \(B\).

Output

Print the number of different pairs \(((i,\ j),\ (k,\ l))\) such that the substrings\(A[i...j]\) and \(B[k...l]\) are equal and the value of \(j-i+1\) is minimum.

Constraints
\(1 \le |A|, |B| \le 10^5\)

2.

Given two integers m & n, find the number of possible sequences of length n such that each of the next element is greater than or equal to twice of the previous element but less than or equal to m.


Example 1:

Input: m = 10, n = 4
Output: 4
Explaination: There should be n elements and
value of last element should be at-most m.
The sequences are {1, 2, 4, 8}, {1, 2, 4, 9},
{1, 2, 4, 10}, {1, 2, 5, 10}.


Example 2:

Input: m = 5, n = 2
Output: 6
Explaination: The sequences are {1, 2},
{1, 3}, {1, 4}, {1, 5}, {2, 4}, {2, 5}.


Your Task:
You do not need to read input or print anything. Your task is to complete the function numberSequence() which takes the number m and n as input parameters and returns the number of sequences.


Expected Time Complexity: O(m*n)
Expected Auxiliary Space: O(1)


Constraints:
1 ≤ m, n ≤ 100

3.

Given an integer N representing the number of pairs of parentheses, the task is to generate all combinations of well-formed(balanced) parentheses.


Example 1:

Input:
N = 3
Output:
((()))
(()())
(())()
()(())
()()()
Example 2:
Input:
N = 1
Output:
()

Your Task:  
You don't need to read input or print anything. Complete the function AllParenthesis() which takes N as input parameter and returns the list of balanced parenthesis.
Expected Time Complexity: O(2N).
Expected Auxiliary Space: O(2*N*X), X = Number of valid Parenthesis.
Constraints:
1 ≤ N ≤ 12
4.

Given a set of numbers from 1 to N, each number is exactly present twice so there are N pairs. In the worst-case scenario, how many numbers X should be picked and removed from the set until we find a matching pair?

Example 1:

Input:
N = 1
Output:
2
Explanation:
When N=1 Then there is
one pair and a matching
pair can be extracted in
2 Draws.

Example 2:

Input:
N = 2
Output:
3
Explanation:
When N=2 then there are
2 pairs, let them be {1,2,1,2}
and a matching pair will
be made in 3 draws.
 

Your Task:
You don't need to read input or print anything. Your task is to complete the function find() which takes an integer N as input parameter and returns an integer, the number of x must be picked and removed from set to find a matching pair.
 

Expected Time Complexity: O(1)
Expected Space Complexity: O(1)
 

Constraints:
0 <= N <= 105

5.

Given a positive integer n. Find the sum of product of x and y such that floor(n/x) = y .
 
Example 1:

Input: n = 5
Output: 21
Explanation: Following are the possible 
pairs of (x, y):
(1, 5), (2, 2), (3, 1), (4, 1), (5, 1).
So, 1*5 + 2*2 + 3*1 + 4*1 + 5*1 
   = 5 + 4 + 3 + 4 + 5 
   = 21.

Example 2:

Input: n = 10
Output: 87
Explanation: Sum of product of all 
possible pairs of (x, y) is 87.

 

Your Task:
You don't need to read or print anything. Your task is to cpmplete the function sumofproduct() which takes n as input parameter and returns the sum of product of all possible pairs(x, y).
 

Expected Time Complexity: O(n)
Expected Space Compelxity: O(1)