## xyz Interview Questions

- 0of 0 votes
First common Ancestor of Binary tree . Java Solution needed.

Class Node {

Node Parent;

Node LeftChild;

Node rightChild;

int val;

}

publlic Node firstAncestor(Node leftNode, Node rightNode){

// We don't get the root node here. From left and right child we need to find it's parent and find the lowest common ancestor.

}

- 0of 0 votes
Problem:

Insert + or – sign anywhere between the digits 123456789 in such a way that the expression evaluates to 100. The condition is that the order of the digits must not be changed.

e.g.: 1 + 2 + 3 – 4 + 5 + 6 + 78 + 9 = 100

I have below C solution - Can you please help me to convert to Java. I need this solution in Java.

#include<stdio.h>

#include<conio.h>

int findnumber(int i,int j)

{

int k;

int n;

for(k = 0; k < j; k++)

{

n = i % 3;

i = i / 3;

}

return n;

}

void main()

{

int i, j, k, current, result, operation;

clrscr();

for(i = 0; i < 19683; i++)

{

if(i%3 == 0)

continue;

current = 0;

result = 0;

for(j = 1; j < 10; j++)

{

k = findnumber(i,j);

if(k==0)

{

current = current * 10 + j;

}

else

{

result = result + (operation == 1 ? current : -current);

current = j;

operation = k;

}

}

result = result + (operation == 1 ? current : -current);

if(result == 100)

{

for(j = 1; j < 10; j++)

{

k = findnumber(i,j);

if(k==0)

printf("%d",j);

else

printf("%c%d",k==1?'+':'-',j);

}

printf("\n");

}

}

getch();

}

- 0of 0 votes
Language : java

Find the length of the non repeated numbers in an array.

Input : 1,2,2,3,4,5,6,2,3

- 0of 0 votes
Given an array of n strings, sentences, where each sentences, consists of most w space-separated words, we want to perform q queries given by an array of q strings named queries where each queries consists of at most k space-separated words. To answer query queriesj, we find all the indices in sentences that contain every word in queries and assemble them into an array of indices listed in ascending order. For example, if all the words in queries are only found in sentences4, sentences9 and sentences2 , then the answer to queriesj is the array[2,4,9].

Input Format:

The first line contains an integer, n, denoting the number of Strings in sentences

Each line i of the n subsequent lines contains at most w space-separated words describing sentences

The next line contains an integer, q, denoting the number of strings in queries

Each line j of the q subsequent lines contains at most k space-separated words describing queries.

1) Sample I/P format:

3

jim likes mary

kate likes tom

tom does not like jim

2

jim tom

likes

O/P:

2

0 1

2) Sample I/P Format:

4

how it was done

are you how

it goes to it

goes done are it

2

done it

it

O/P:

0 3

0 2 2 3

Note: Solution in Java only

static void searchQueries(String[] sentences, String[] queries) {

}

- 0of 0 votes
Language : Java

Given a binary tree, print boundary nodes of the binary tree counter-clockwise starting from the root.

For example, boundary traversal of the following tree is “20 8 4 10 14 25 22”

20

8 22

4 12 25

10 14

- 0of 0 votes
Design a system to support a pool of servers. The pool Api should be able to add a server, get a server (can be random) and delete a server from the pool.

You need to design and implement an interface for such pool.

The pool implementation should operate with a high performance so all operations need to be done in O(1).

- 0of 0 votes
Given the N*N matrix, find the given number in the matrix. All rows are sorted. And each row first element is less than the previous row last index.

input :

[1,3,5,7,9]

[11,13,15,16,20]

[21,22,23,24,25]

[30,32,35,40,45]

Given Num : 23

What is the best Optimal solution ? I have used BST but the interviewer asked to use any other which could do better in the above scenario.

- 0of 0 votes
Given the below input and ouput.

Input :

String[] input = {"hello", "world"};

output: (Higher count should come before and natural order)

hello : l=2, e=1,h=1,o=1

world: d=1,l=1,o=1,r=1,w=1

- 0of 0 votes
Given the below input and output and asked to write in Java.

Example 1)

input : {1,2,3,4, &, 12,13,14,15}

output : {15,14,13,12,1,2,3,4}

Example 2 )

input : {33,34,&,55,63}

output : {63,55,33,34}

Assumption : '&' will always be in the middle.

- -2of 2 votes
How to bring back ex lost love back with in 24 hours

- 0of 0 votes
Y can't user mode helper function execute ls command .

It is executing my application and even power off command.

Please let me know how user mode helper function works briefly...

- 0of 0 votes
How to annihilate twisted FB issues via Facebook Customer Service 1-877-470-3053?

- 0of 0 votes
How to Do Business On FB? Grab Facebook Customer Service 1-877-470-3053

- 0of 0 votes
How to Edit Temporary Profile Photo? Get Facebook Customer Service 1-877-470-3053

- 0of 0 votes
How to use Facebook for promotion via Facebook Customer Service 1-877-470-3053?

- 0of 0 votes
Design a movie ticketing system where ticket prices goes up or down based on demand. If no tickets were booked in the last 4 hours, the prices should fall by 10%

- -2of 2 votes
Gmail Technical support number: Maximum personality advocated making smooth communication to save your phone bill. Hence, they are addicted into in built chatting service and incredible Gmail tech support. Even through filling the accurate credential details in the form of the user name and password, establishing the user friendly communication without the error message and prompt is not easy task. If you are getting difficulty to access your account to enjoy all cheered function, then you should have to get assistance of expert through dialing Gmail technical support phone number +44-8000-9039-09. Otherwise, you will have to bear several losses in the Gmail account. Our team is offering support at nominal price value. At the peak of urgency, you should have to dial our toll free number.

for more info visit-http://www.customer-emailsupportnumber.com/gmail-support.html

- 0of 0 votes
How to print from 3rd column to till last columns using awk command in unix, if there are 'n' columns in a file.

- 0of 0 votes
Given a string consisting only of digits, find the missing number. For instance, given the string 596597598600601602 the missing number is 599. You may assume all the numbers are positive integers and the sequence increases by one at each number except the missing number. The numbers will have no more than six digits and the string will have no more than four hundred characters.

Your task is to write a function to find the missing number in the sequence. If there should no missing number whatsoever, return a value of -1

- 0of 0 votes
a = 0, b=0, c=1 are the 1st three terms. All other terms in the Lucas sequence are generated by the sum of their 3 most recent predecessors.

Write a program to generate the first n terms of a Lucas Sequence.

- 0of 0 votes
JSON PARSING ( Print all the data from a Json String).

Input : {'firstname' : 'abc'}

Output : firstname -> abc

Input : {'firstname' : 'abc', 'lastname' : 'Lincoln'}

Output : firstname -> abc lastname -> Lincoln

Input : {'address' : '365 KG', 'lastname' : 'Lincoln'}

Output : address -> 365 KG lastname -> Lincoln

Ideally, you must parse the JSON string into a map data, and then print out the elements of the map. Among other things, it will help print out the data in alphabetical order as well.

- 0of 0 votes
Find number of islands of '1' in D dimensional array containing '0', '1'. where D > 2.

- 0of 0 votes
How can save money, while moving?

- 0of 0 votes
I run ansible, but the remote machine suddenly down at the middle of the proccess? How do I fix it?

- 0of 0 votes
Running ansible with my own script (say 1.0). But, for a month later, I've updated the ansible scripts more and more. And the remote machine need to orchestrate even provision again. How do I know that I can rollback to the state of ansible script version I used?

- 0of 0 votes
An Integer array is given,

Find the combination of number in the array which satisfies the equation: a to the power b= c.

A number should not be repeated in multiple combination.

1. a and b are adjacent no. in the array.c can be any where in the array.

2.No other array or data structure can be used. However modification of current array is possible.

Define a function which will take array as input and generate a output array (a modification of input array).

Example: Input array: 1 2 3 8 5

out put: 2 3 8 0 0

- 0of 0 votes
Given a binary tree, we are supposed to find nth smallest element.

- 0of 0 votes
You have table defining meta data for all tables in your system

col name | table name | primary key| foreign key|

design a algorithm to generate sql dynamically based on column selection.

- 0of 0 votes
Write a function that will operate on a C-string and convert all instances of "AB" to "C" without using a second string for temporary storage. Use the following function signature:

void translate(char *str)

So for example:

char astring[] = "helloABworld";

translate(astring);

// Now astring holds "helloCworld";

Your function should handle strings of arbitrary length.

- 0of 0 votes
What is the maximum leads that can be generated from ad budget of 30k. Below is the table provided:

Budget 10000 20000 30000 40000 50000

Display Leads 500 1000 1200 1500 1700

SEO Leads 1000 1500 1700 1900 2500