Detail Form
We will send your result on your email id and phone no. please fill detail
Given a sorted array of size N and an integer K. Check if K is present in the array or not.
Example 1:
Example 2:
Your Task:
You don't need to read input or print anything. Complete the function searchInSorted() which takes the sorted array arr[], its size N and the element K as input parameters and returns 1 if K is present in the array, else it returns -1.
Expected Time Complexity: O(Log N)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 106
1 <= K <= 106
1 <= arr[i] <= 106
Dilpreet wants to paint his dog- Buzo's home that has n boards with different lengths[A1, A2,..., An]. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.The problem is to find the minimum time to get this job done under the constraints that any painter will only paint continuous sections of boards, say board {2, 3, 4} or only board {1} or nothing but not board {2, 4, 5}.
Input:
The first line consists of a single integer T, the number of test cases. For each test case, the first line contains an integer k denoting the number of painters and integer n denoting the number of boards. Next line contains n- space separated integers denoting the size of boards.
Output:
For each test case, the output is an integer displaying the minimum time for painting that house.
Constraints:
1<=T<=100
1<=k<=30
1<=n<=50
1<=A[i]<=500
Example:
Explanation:
1. Here we can divide the boards into 2 equal sized partitions, so each painter gets 20 units of the board and the total time taken is 20.
2. Here we can divide first 3 boards for one painter and the last board for the second painter.
Given two unsorted arrays arr1[] and arr2[]. They may contain duplicates. For each element in arr1[] count elements less than or equal to it in array arr2[].
Example 1:
Example 2:
Your Task :
Complete the function countEleLessThanOrEqual() that takes two array arr1[], arr2[], m, and n as input and returns an array containing the required results(the count of elements less than or equal to it in arr2 for each element in arr1 where ith output represents the count for ith element in arr1.)
Expected Time Complexity: O((m + n) * log n).
Expected Auxiliary Space: O(1).
Constraints:
1<=m,n<=10^5
1<=arr1[i],arr2[j]<=10^5
A Hamiltonian path, is a path in an undirected or directed graph that visits each vertex exactly once. Given an undirected graph the task is to check if a Hamiltonian path is present in it or not.
Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains two lines. The first line consists of two space separated integers N and M denoting the number of vertices and number of edges.Then in the next line are M space separated pairs u,v denoting an edge from u to v.
Output:
For each test case in a new line print 1 if a Hamiltonean path exists else print 0.
Constraints:
1<=T<=100
1<=N<=10
1<=M<=15
Example:
Given a linked list of strings having n nodes check to see whether the combined string formed is palindrome or not.
Input:
You have to complete the method which takes one argument: the head of the linked list . You should not read any input from stdin/console.. There are multiple test cases. For each test case, this method will be called individually.
Output:
Your function should return True if the combined string is pallindrome else it should return False.
User Task:
The task is to complete the function compute() which returns true or false.
Constraints:
1 <=T<= 103
1 <=n<= 103
Example:
Input :
2
5
a bc d dcb a
4
a bc d ba
Output :
True
False