## Recent Interview Questions

More Questions »- 0of 0 votes
Write a Java code that take a string of parenthesis as input and return if the string is valid or not . The input will have '(' and ')' and also '*' and * serves as wild card and can be used in place of both '(' and ')' or it can be null.

For example,the String (*)(*)(** is a valid String.

Follow up: What if '[]' and '{}' are also in the string along with '()' and * can be used in place of any of them or can be considered as null?

- 0of 0 votes
given two array of elements representing the connection Nodes output the topology used?

Topology can be either Bus , circular or Star

input:

Number of nodes 3

Number of Connections : 2

{1,2}

{2,3}

Output Bus

Explanation

the topology formed would be 1->2->3 . hence Bus

input

number of nodes : 3

Number of connections : 3

{1,2,3}

{2,3,1}

Output: Circular

the topology formed is 1->2->3->1

hence circular

input:

number of nodes : 5

Number of connections : 5

2 3 4 5

1 1 1 1

Answer : StarTopology

Explanation : A star can be formed with this input

2 4

1

3 5

StarTopology

- 0of 0 votes
Magical binary strings are non-empty binary strings if the following two conditions are true:

1. The number of 0's is equal to the number of 1's.

2. For every prefix of the binary string, the number of 1's should not be less than the number of 0's.

A magical string can contain multiple magical substrings. If two consecutive substrings are magical, then we can swap the substrings as long as the resulting string is still a magical string. Given a magical binary string, str, perform zero or more swap operations on its consecutive magical substrings such that the resulting string is as lexicographically large as possible. Two substrings are considered to be consecutive if the last character of the first substring occurs exactly one index before the first character of the second substring.

Input Format

a single binary string, str.

Constraints

It is guaranteed that str is a binary string of 1's and 0's only.

1 ≤ length(str) ≤ 50

It is guaranteed that str is a magical string.

Output Format

Find a string denoting the lexicographically largest magical string that can be formed from str.

Sample Input 0

11011000

Sample output

11100100

Explanation of sample

Given the magical string str = 11011000, we can choose two consecutive magical substrings, 1100 and 10, to swap such that the resultant string, str' = 11100100, is the lexicographically largest possible magical string possible. Thus, we return the value of str', which is 11100100, as our answer.

- 0of 0 votes
`A text file contains {candidateID,voterID} details of an ongoing voting. Read this file in real time and report top 5 candidates. Also report a fraud if a Voter tries to vote twice or try to vote more then one candidate. Assume that the database is offline.`

- 0of 0 votes
Given an unsorted array of unique integers, find two numbers in the array whose sum is equal to a given number.