Detail Form
We will send your result on your email id and phone no. please fill detail
Trie is an efficient information retrieval data structure. Use this data structure to store Strings and search strings. Your task is to use TRIE data structure and search the given string A. If found print 1 else 0.
Example 1:
Example 2:
Your Task:
Complete insert and search function and return true if key is present in the formed trie else false in the search function. (In case of true, 1 is printed and false, 0 is printed by the driver's code.
Expected Time Complexity: O(M+|search|).
Expected Auxiliary Space: O(M).
M = sum of the length of all strings which is present in the key[]
|search| denotes the length of the string search.
Constraints:
1 <= N <= 104
1 <= |input strings|, |A| <= 100
Given a binary matrix your task is to find all unique rows of the given matrix.
Example 1:
Your Task:
You only need to implement the given function uniqueRow(). The function takes three arguments the first argument is a matrix M and the next two arguments are row and col denoting the rows and columns of the matrix. The function should return the list of the unique row of the martrix. Do not read input, instead use the arguments given in the function.
Note: The drivers code print the rows "$" separated.
Expected Time Complexity: O(row * col)
Expected Auxiliary Space: O(row * col)
Constraints:
1<=row,col<=40
0<=M[][]<=1
Given an array of integers of size N find minimum xor of any 2 elements.
Example 1:
Your Task:
You don't need to read input or print anything. Your task is to complete the function minxorpair() which takes the array arr[], its size N as input parameters and returns the minimum value of xor of any 2 elements.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Constraints:
1 <= N <= 105
1 <= arr[i] <= 105
Given an array arr containing N words consisting of lowercase characters. Your task is to find the most frequent word in the array. If multiple words have same frequency, then print the word whose first occurence occurs last in the array as compared to the other strings with same frequency.
Example 1:
Example 2:
Your Task:
Complete mostFrequentWord function which takes array of strings and its length as arguments and returns the most frequent word. The printing is done by the driver code.
Expected Time Complexity: O(N * WORD_LEN).
Expected Auxiliary Space: O(N * WORD_LEN).
Constraints:
1 <= N <= 5000
1 <= |each string| <= 50
You are given an array nums. Your task is to complete the function gtXor to return the XOR of the given range a and b.
Example 1:
Example 2:
Your Task:
You don't need to read or print anyhting. Your task is to comlplete the function getXor() which takes nums, a and b as input parameter and returns the xor from a to b.
Expected Time Complexity: O(n)
Expected Space Complexity: O(1)
Constraints:
1 ≤ n ≤ 105
0 ≤ a ≤ b ≤ n
1 ≤ nums[i] ≤ 100