Detail Form
We will send your result on your email id and phone no. please fill detail
Given a string str and another string patt. Find the character in patt that is present at the minimum index in str. If no character of patt is present in str then print ‘No character present’.
Input:
The first line of input contains an integer T denoting the number of test cases. Then the description of T test cases follow. Each test case contains two strings str and patt respectively.
Output:
Output the character in patt that is present at the minimum index in str. Print "$" (without quotes) if no character of patt is present in str.
User Task:
The task is to complete the function printMinIndexChar() which finds the character in patt that is present at minimum index in str.
Constraints:
1 <= T <= 105
1 <= |str|, |patt| <= 105
Example:
Explanation:
Testcase 1: e is the character which is present in given patt "mytat" and is first found in str "set".
Example Problem 1 : Range Minimum Query
We have an array arr[0 . . . n-1]. We need to efficiently find the minimum value from index L (query start) to R (query end) where 0 <= L <= R <= n-1. Consider a situation when there are many range queries.
Example:
The idea is to precompute minimum of all subarrays of size 2j where j varies from 0 to Log n. We make a table lookup[i][j] such that lookup[i][j] contains minimum of range starting from i and of size 2j. For example lookup[0][3] contains minimum of range [0, 7] (starting with 0 and of size 23)
How to fill this lookup or sparse table?
The idea is simple, fill in a bottom-up manner using previously computed values. We compute ranges with current power of 2 using values of lower power of two. For example, to find a minimum of range [0, 7] (Range size is a power of 3), we can use the minimum of following two.
a) Minimum of range [0, 3] (Range size is a power of 2)
b) Minimum of range [4, 7] (Range size is a power of 2)
Based on above example, below is formula,
// Minimum of single element subarrays is same // as the only element. lookup[i][0] = arr[i] // If lookup[0][2] <= lookup[4][2], // then lookup[0][3] = lookup[0][2] If lookup[i][j-1] <= lookup[i+2j-1][j-1] lookup[i][j] = lookup[i][j-1] // If lookup[0][2] > lookup[4][2], // then lookup[0][3] = lookup[4][2] Else lookup[i][j] = lookup[i+2j-1][j-1]
Given a sorted doubly linked list of distinct nodes(no two nodes have the same data) and a value x. Count triplets in the list that sum up to a given value x.
Examples:
Given a sequence of n integers, . You are asked to perform the following operation and return the obtained result.
For a given integer x calculate the value of the expression:
returns the value of the rightmost number with highest number of distinct prime factors.
In other words, if , then you have to find the value of .
Input
The first line of input contains two integers, x and n.
Followed by n integers, .
Output
Print an integer denoting the value of the expression.
Constraints
Given, an array A containing N elements. Perform the following two queries on this given array:
0 L R - Print out the value of the required summation .
1 X V - Change the value of the number at position to V .
Note:
Indexing is 1 based.
Input format
Output format
Output the answer for each query type 0 L R in a separate line.
Constraints
Given a String S , print the reverse of the string as output.
Example 1:
Example 2:
Your Task:
You dont need to read input or print anything. Complete the function revStr() which takes S as input parameter and returns the reversed string .
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(|S|)
Constraints:
1<= |S| <=1000
Given a string S. The task is to convert characters of string to lowercase.
Example 1:
Example 2:
Your Task:
You dont need to read input or print anything. Complete the function toLower() which takes S as input parameter and returns the converted string.
Expected Time Complexity:O(n)
Expected Auxiliary Space: O(1)
Constraints:
1 <= |S| <= 1000
Given an array of strings, return all groups of strings that are anagrams. The groups must be created in order of their appearance in the original array. Look at the sample case for clarification.
Example 1:
Example 2:
Your Task:
The task is to complete the function Anagrams() that takes a list of strings as input and returns a list of groups such that each group consists of all the strings that are anagrams.
Expected Time Complexity: O(N*|S|*log|S|), where |S| is the length of the strings.
Expected Auxiliary Space: O(N*|S|), where |S| is the length of the strings.
Constraints:
1<=N<=100