Questions

Given an unsorted array of n elements, find if the element k is present in the array or not.
Complete the findNumber function in the editor below. It has 2 parameters:
  1. An array of integers, arr, denoting the elements in the array.
  2. An integer, k, denoting the element to be searched in the array.
The function must return a string "YES" or "NO" denoting if the element is present in the array or not.

Input Format

The first line contains an integer n, denoting the number of elements in the array arr.
Each line i of the n subsequent lines (where 0 ≤ i < n) contains an integer describing arri.
The next line contains an integer, k, the element that needs to be searched. 

Constraints
  • 1 ≤ n ≤ 105
  • 1 ≤ arr[i] ≤ 109

Output Format
The function must return a string "YES" or "NO" denoting if the element is present in the array or not. This is printed to stdout by locked stub code in the editor.

Explanation 0
Given the array = [1, 2, 3, 4, 5], we want to find the element 1 if it is present or not. We can find the element 1 at index = 0. Therefore we print "YES".

Explanation 1
Given the array [2, 3, 1] and k = 5. There is no element 5 in the array and therefore we print "NO".

------------------------------------
Odd Numbers : 
Given two integers, l and r, print all the odd numbers between l and r (l and r inclusive)

Complete the oddNumbers function in the editor below. It has 2 parameters:
  1. An integer, l, denoting the left part of the range.
  2. An integer, r, denoting the right part of the range.
The function must return an array of integers denoting the odd numbers between l and r.

Input Format
Locked stub code in the editor reads the following input from stdin and passes it to the function:
The first line contains an integer, l, denoting the left part of the range.
The second line contains an integer, r, denoting the right part of the range.

Constraints
  • 1 ≤ l ≤ r ≤ 105

Output Format
The function must return an array of integers denoting the odd numbers between l and r. This is printed to stdout by locked stub code in the editor.

Explanation 0
The value of l is 2 and value of r is 5. The odd numbers between [2, 5] are 3 and 5.


-------------------
Which of the following sorting algorithms has the best asymptotic runtime complexity?
Pick one of the choices

Comments

Popular posts from this blog

RUN JAVA PROJECT IN ANDROID STUDIO

Gradle DSL method not found: 'compile()'

Reverse string using recursion