## Recent Interview Questions

- 0of 0 votes
The SHIELD is a secretive organization entrusted with the task of guarding the world against any disaster. Their arch nemesis is the organization called HYDRA. Unfortunately some members from HYDRA had infiltrated into the SHIELD camp. SHIELD needed to find out all these infiltrators to ensure that it was not compromised.

Nick Fury, the executive director and the prime SHIELD member figured out that every one in SHIELD could send a SOS signal to every other SHIELD member he knew well. The HYDRA members could send bogus SOS messages to others to confuse others, but they could never receive a SOS message from a SHIELD member. Every SHIELD member would receive a SOS message ateast one other SHIELD member, who in turn would have received from another SHIELD member and so on till NickFury. SHIELD had a sophisticated mechanism to capture who sent a SOS signal to whom. Given this information, Nick needed someone to write a program that could look into this data and figure out all HYDRA members.

Sample Input

Nick Fury : Tony Stark, Maria Hill, Norman Osborn

Hulk : Tony Stark, HawkEye, Rogers

Rogers : Thor,

Tony Stark: Pepper Potts, Nick Fury

Agent 13 : Agent-X, Nick Fury, Hitler

Thor: HawkEye, BlackWidow

BlackWidow:Hawkeye

Maria Hill : Hulk, Rogers, Nick Fury

Agent-X : Agent 13, Rogers

Norman Osborn: Tony Stark, Thor

Sample Output

Agent 13, Agent-X, Hitler

You can code in any language of your choice. Input and Output must be in the same format as above

- 0of 0 votes
asdf

- 0of 0 votes
You have 9 balls. 8 of them weigh the same, but one of them weighs heavier than the other 8.

How can we find the heaviest weighted ball in no more than 2 operations?

- 0of 2 votes
Given an array A[1...N] of positive integers, you have to sort it in ascending order in the following manner : In every operation, select any 2 non-overlapping sub-arrays of equal length and swap them. i.e, select two sub-arrays A[i...(i+k-1)] and A[j...(j+k-1)] such that i+k-1< j and swap A[i] with A[j], A[i+1] with A[j+1] ... and A[i+k-1] with A[j+k-1].

**Example:**

For n=6

6 7 8 1 2 3

Only one operation is needed as after swapping (6 7 8) and (1 2 3 ) sub arrays

we can get 1 2 3 6 7 8 , that is sorted.

How can we figure out minimum number of swaps in most effective way ?

- 0of 0 votes
Scenario : Multi Seller E-commerce Website

Given a list of products in a customer basket find the minimum number of seller required to deliver his order,so as to optimise shipping part.

Assuming you have already have below data

Customer orders products : P1,P2,P3,P4,P5,P6

Products and seller mapping

P1 = [1,2,3,4]

P2=[2,4,5,6]

where 1,2,3 etc denotes seller_ids.

p1

- 0of 0 votes
Find popular item in sorted array of natural numbers.

An item is popular is if its repeated n/4 times or more.

For Ex:

Input: 123444445678

Popular item is 4.

Liner scan is O(n), but solution needs to be in O(logN) complexity and O(1) space complexity.

- 0of 0 votes
Given a string containing letter, digit, and other characters, write a function to check palindrome for only letter and digit. The implementation need to be in-place, no extra memory is allowed to create another string or array.

For example:

"ABA" is palindrome

"A!#A" is palindrome

"A man, a plan, a canal, Panama!" is palindrome

- 0of 0 votes
an array contains number in range 1 to n and having a number missing and a number repeat twice find both numbers

- 1of 1 vote
given a string without space "iamstudent" output "i am student" u are provided with a dictionary to check words

- 0of 0 votes
Write a program that reverses a linked list without using more than O(1) storage.

- 0of 0 votes
Write a program that answers YES/NO search queries containing * placeholders. Example: if the data you have is (hazem, ahmed, moustafa, fizo), then you should answer as follows for:

ahmed: YES

m**stafa: YES

fizoo: NO

fizd: NO

*****: YES

****: YES

**: NO

Your program should be able to answer each search query in O(1).

- 0of 0 votes
If I was a marketer for a large company, tell me how I can increase the number of likes I have on my Facebook business page to 5 million?

- 4of 4 votes
You are given an unsorted sequence of integers 'a'. Find the longest subsequence 'b' such that elements of this subsequence are strictly increasing numbers. Elements in the subsequence 'b' must appear in the same relative order as in the sequence 'a'. You may assume that 'a' can fit to the memory.

Example:

input: a = [-1 2 100 100 101 3 4 5 -7]

output: b = [-1 2 3 4 5]

- 0of 0 votes
In a single pass, find Nth node from last in a Linked List.

{ N can be any value. }

- 0of 0 votes
To within a constant factor, how much time does the following algorithm take, in terms of n?

twoToTheN(n)

if n == 1

return 0

else

return twoToTheN(n-1) + twoToTheN(n-1)

- 0of 0 votes
A polygon is a piecewise-linear, closed curve in the plane. That is, it is a curve

ending on itself that is formed by a sequence of straight-line segments, called the

sides of the polygon. A point joining two consecutive sides is called a vertex of

the polygon. If the polygon is simple, as we shall generally assume, it does not

cross itself. The set of points in the plane enclosed by a simple polygon forms the

interior of the polygon, the set of points on the polygon itself forms its boundary,

and the set of points surrounding the polygon forms its exterior. A simple polygon

is convex if, given any two points on its boundary or in its interior, all points on

the line segment drawn between them are contained in the polygon’s boundary or

interior.

Professor Amundsen proposes the following method to determine whether a sequence

hp0, p1, . . . , pn−1i of n points forms the consecutive vertices of a convex

polygon. Output “yes” if the set {6 pi pi+1 pi+2 : i = 0, 1, . . . , n − 1}, where sub

script addition is performed modulo n, does not contain both left turns and right

turns; otherwise, output “no.” Show that although this method runs in linear time,

it does not always produce the correct answer. Modify the professor’s method so

that it always produces the correct answer in linear time.

- 0of 0 votes
Input any string, count the maximum depth of parenthesis nesting, i.e. "abc(123(xyz))m(((n)))o" -> 3.

if input is null or contains a mismatch "a)b(c" or "a(b"

Also some other samples:

(((()))) -> 4

()()()() -> 1

- 0of 0 votes
Consider the 52 cards of a deck. You generated a random sequence for these cards and want to send that sequence to a receiver. You want to minimize the communication between you and the receiver, i.e., minimize the number of bits required to send the sequence.

What is the minimum number of bits required to send the sequence?

Hint: It is not 6 x 52

- 1of 1 vote
Input: A string equation that contains numbers, '+' and '*'

Output: Result as int.

For example:

Input: 3*5+8 (as String)

Output: 23 (as int)

- 0of 0 votes
Given a class Range

`class Range { public int begin; public int end; public Range(int begin, int end) { this.begin = begin; this.end = end; } }`

The problem:

Intput:

1) list of Ranges that don't overlap (not sorted)

2) newRange that might overlap.

Output:

list of merged Ranges

For example:

Input: [1..5] [9..13] [17..22]

newRange: [4..10]

Output: [1..13] [17..22]

- 0of 0 votes
Find the number of substrings of 2 strings that are palindromes.

- 0of 0 votes
On a table there are four papers, one with the letter X written on top, one with the letter Y written on top, one with the number 1 written on top, and one with the number 2 written on top. Every paper has one of those letters on one side and one of those numbers on the other side. To prove that a paper with the letter x contains even number on the other side, what is the minimum number of conditions we have to check?

- 0of 0 votes
How would you get all of the unique IDs out of a single file? What if it was a very large file?

- 0of 0 votes
to print pattern

p

Pu

pUl

PuLc

pUlCh

PuLcHo

pUlChOw

PuLcHoWk

- 0of 0 votes
command which will tell all the running process and amount memory consumed by them

- -1of 1 vote
Garbage collection in java

- 0of 0 votes
find the max length of name(1stName+2ndName+MiddleName) table value.

- 0of 0 votes
Convert a binary tree into a In Order traversal circular list re-purposing the node's pointers Left & Right as Previous and Next respectively.

Hint: A single node Left & Right points to itself.

Note: This is not a binary search tree.

- 1of 3 votes
New CareerCup Android App!!!

Hey Guys,

Lately I was trying to get android app for this website and no single app was good enough for me.

So I thought of developing it myself. After 2 weekends of work I released first version of the app. With lot more new features lined up.

Please download it here

https://play.google.com/store/apps/details?id=com.careercup

and give your reviews and ratings.

Thanks

- 1of 1 vote
A plumber working for a company as a contractor. His job is attend services and submit the bill to get his salary on basis of daily work including his service charge 500 rupees. For a typical plumbing work he need pipes with different lengths. But in market he will get new pipe with standard size 100m of cost 100 rupees. (no small or large sized pipes available) Now , he need 10 , 40 , 60, 70 lengths of pipes for a jobwork.

Generally company gives him (4 pipes * 100 rupees) + 500rupees as service charge = 900 rupees.

but plumber bought only 2 pipes cut as follows and get his job done...

1st pipe => 40+60

2nd pipe => 10+70 + extra left(20)

By buying only 2 pipes he get his job done. remaining 2 pipes money saved.

write an efficient algorithm to calculate minimum number of standard size pipes required for given number of different pipes lengths:

Input:

N => total pipes for jobwork

arr[N] => lengths of pipes. (for simplicity, pipe size will be either smaller or equal to standard size)

outpud:

minimum statdard sized(100m) pipes required

constraint: you can only cut them can not join them back as follows

say he need 10 95 95,

with two pipes 100 100 = > 95+5 95+5 => 95 95 (5+5)// this is not accepted

EX:

Input:

5

20 30 50 60 80

output:

3

Input:

5

10 10 10 15 20 35 55 60 70 75 75 80

output:

6