0% found this document useful (0 votes)
1 views

Coderpad_Questions

Uploaded by

Krishna Rama
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Coderpad_Questions

Uploaded by

Krishna Rama
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 8

S.No.

8
9

10
11
12
13
14

15

16

17

18

19

20

21

22

23

24

25
26
27
28
29

30
31

32
33

34

35

36

37

38
39

40

41
42
43
44
45

46

49

50
Question
Convert this string (aabbb into a2b3) , (aaaa into a4), (a into a1).

Given a string as letters (“ODG”) find the longest cord which matches this cord in a dictionary given (full of s

5
Find the in order traversal method
Submission
3 7

Find the smallest element in an array

[ 0, 0]
UUU [0, 3]
LLL [-3, 0]
RRR [ 3, 0]
PPP [ 0, -3]

URL 0, 1
1,1
0,1

Given a string with the input value

URLD

Run Length Encoding' snippet (javascript, Easy)

'Median Two Sorted Arrays' snippet (javascript, Medium)


24. Hashmap – Internal implementation
- Put/ Get methods
- How do you scale it

Prefix search - ‘Given document, give one prefix -> need to search Document for ‘all occurrences of the prefi
Non repeating character in string (1st Chain).
(1,2,3,4)
(2,2,3,3,4) Input 1 Input 2
3/2 Output

Length of Subarray – 6

To find the first non-repeating character in a string


Coding of a string and coding of repetitive patterns, dynamic programming question. Program name is Magic
To find the most frequent IP address in a given vector.
Finding median of 2 sorted arrays.
String was given and he had to write the function to find the min distance between the mid element of two w
Given a string which we have to convert into integer. The string can be in form of either positive, negative, A
or special characters. – (atoi function)
Find minimum element in sorted rotated array. The time complexity should be O (logn).
We have a chess board and there is a immoveable piece which cannot move in any direction, and we have a
which can only move diagonally. Find if we can reach the immovable piece using bishop and in how many m
steps.
Find maximum average from a list in which the marks obtained of a student can be positive or negative and
may have multiple marks.
Find the minimum element in rotational Array. With time complexity o(logn).
Resolve the issue of program reverse String test.(we need to check and remove first if condition inside rever
method).
Implement a function that takes in an array of non-negative numbers and an integer. You want to return the
the shortest subarray whose sum is at least the integer and -1 if no such sum exists.
Check whether a number is a power of 10.

A group of students are sitting in a circle. The teacher is electing a new class president. The teacher does th
a song while walking around the circle. After the song is finished the student at which the teacher stopped
from the circle. Starting at the student next to the one that was just removed, the teacher resumes singing a
around the circle. After the teacher is done singing, the next student is removed. The teacher repeats this u
student is left.
A song of length k will result in the teacher walking past k students on each round. The students are number
The teacher starts at student 1.
For example, suppose the song length is two(k=2). And there are four students to start with (1,2,3,4). The fir
to go would be '2', after that '4', and after that '3’. Student '1' would be the next president in this example.

*@param n the number of students sitting in a circle


*@param k the length (in students) of each song.
*@return the number of the student that is elected

Find maximum average of student


{{“Charles”, 84},
{“John”, 100},
{“Andy”, 67},
{“John”, 22}}
O/P: - 84

Explain the difference between hashmap and concurrent Hashmap.


Check whether a number is power of 10 or not.
Find the tree with largest number of nodes in a forest and return the root of the tree.
find the root with a minimum id of the largest tree in a
forest.
Find maximum average of student
{{“Charles”, 84},
{“John”, 100},
{“Andy”, 67},
{“John”, 22}}
O/P: - 84
Given a string as letters (“ODG”) find the longest cord which matches this cord in a dictionary given (full of string
Given a forest(one or more disconnected trees ), find the root of the largest tree
i/p: child -> parent relationship. The key is the child and value is the corresponding tree.
{{1 -> 2}, {3->4}}
o/p:
2(since 2 is less than 4)
Find pivot in an array.
Reverse Vowels in a String.
There is a sentence s which has some words. Return the list of indices of all the words that starts with a
prefix.
For Example:
String str = “a aa aaa abca bca”
String prefix = “bc”
output = 14
1. Debug a code and correct it.
- Need to print string in reverse order.
- All test cases should pass.
- There were multiple errors in the code, like in the first if condition it was given that
if(str.length >=0) return 0; correction=> if(str.length <=0) return 0;
Change in for loop; correction=> remove the incremented variable
- Add different test cases to check if it is giving expected output or not.

Find and return the maximum average of student's scores from a given input.
- input array can be like String[][] students = new String[][] {{"xyz","20"},{"pqr","30"},{"xyz","51"},{"pqr","3
expected output is 40
- Needed to use Math.floor() function.
- input can have negative values also. String[][] students = new String[][] {{"xyz","-20"},{"pqr","-60"},{"xy
{"mnp","-39"}}; // expected output is -36
Given an array find if its cyclic
Example - startIndex = 0, arr= [1,0] ==> cycle length = 2
Example - startIndex = 0, arr= [2,0,1] ==> cycle length = 3

Graph of Stations, find the shortest path from source to destination


1) There is a function which return string (int numerator, int denominator){

The repeating number should be in brackets.


numerator = 1, denominator = 2 , output should be 0.5
numerator = 1, denominator = 3 , output should be 0.(3)
}
Two dimensional string array, where column 1 contains name, column2 contains marks, where names are repeating in the
need to write the function to find the highest average.
Check whether a number is a power of 10. (Both positive and negative powers of 10)
Given a forest(one or more disconnected trees ), find the root of the largest tree.
i/p: child -> parent relationship. The key is the child and value is the corresponding tree.
{{1 -> 2}, {3->4}}
Given a log file which contains ip address and details of each process in each line, return the most repeated process in the
Given a list of words, group them into anagrams. And return the set of of anagrams.
Find the second smallest number from an array.
For the input : [101,45,134,445,55,2]
output : return value as 45 which is the second smallest number.
Return the highest avg. score of a person from the given input:
For the input : String[][] arr = [["name1","43"], ["name2","68"], ["name3","29"], ["name2","100"]]
output : return value as 84 which is the max avg score among the given list.
Snowpack problem - Given an array of non-negative integers representing the elevations,
many units of snow could be captured between the hills.
Return all indexes for an input string within a sentence.

You might also like