## Yahoo Interview Questions

- 0of 0 votes
2.{{ Query the sum of all the data values in a given rectangle (x1,y1) ~(x2, y2).

int querySum(int x1, int y1, int x2, y2) {}}}

- 0of 0 votes
{{Given a two dimensional grid that stores data as integers with the size of N*M, implement write and query functions which supports:

1. Write the given value to designated coordination (x, y).

void write(int value, int x, int y) {}

}}

- 0of 0 votes
Given a nxn matrix, with partially filled cells of numbers from 1..n and the rest with 0's. Fill the cells such each row and column has numbers 1 to n without any repetition.

Eg:

[

[1, 2, 0],

[0, 1, 0],

[0, 0, 1]

]

[

[1, 2, 3],

[3, 1, 2],

[2, 3, 1]

]

- 0of 0 votes
What is indexing in a database?

What are the underlying data structures you think are involved in indexing of a database?

What are some upsides and downsides of using indexing?

- 0of 0 votes
Given an array of integers. Find the surpasser count of each element of the array.

"A surpasser of an element of an array is a greater element to its right"

ex -

Input: [2, 7, 5, 3, 0, 8, 1]

Output: [4, 1, 1, 1, 2, 0, 0]

- 1of 1 vote
Given an array of integers and a sum 'S'. Find 2 integers in the array that add up to S.

- 0of 0 votes
Find the first unrepeated character in a given string. Solve this in a single pass.

- 0of 0 votes
you have a array nums as input. For any i from 0 to length - 1. should print product of whole array except nums[i]

For example: nums = [2,3,1,4,3,2]

output:

72

48

144

36

48

72

- 0of 2 votes
What is RESTful design.

- 3of 3 votes
Given a String find the first non repeating char in a single pass of the string.

Assume a big character set like utf-8 (eleminate use of char[256])

Avoid any subloop to have a very optimal solution

- 1of 1 vote
write custom pattern match function to match following logic

.’ Matches any single character.

‘*’ Matches zero or more of the preceding element.

The matching should cover the entire input string (not partial).

The function prototype should be:`bool isMatch(const char *s, const char *p) Some examples: isMatch(“aa”,”a”) → false isMatch(“aa”,”aa”) → true isMatch(“aaa”,”aa”) → false isMatch(“aa”, “a*”) → true isMatch(“aa”, “.*”) → true isMatch(“ab”, “.*”) → true isMatch(“aab”, “c*a*b”) → true isMatch(“ccca”, “c*a”) → true`

- 1of 1 vote
`Given an array of n integers, return the maximum PMEAN of all possible array rotations, where PMEAN = the sum of each integer multiplied by its current location (index + 1). For example: The PMEANs for every rotation of the array {20, 30, 10} are: PMEAN1 = (1 * 20) + (2 * 30) + (3 * 10) = 110 PMEAN2 = (1 * 30) + (2 * 10) + (3 * 20) = 110 PMEAN3 = (1 * 10) + (2 * 20) + (3 * 30) = 140 The max PMEAN of array {20, 30, 10} is 140.`

The question is simple enough. I was able to get a working algorithm quick enough, but I failed to optimize my answer.

Hint from the interviewer:

If you have PMEANn, how can you use the result to get PMEANn+1?

- 0of 0 votes
IEEE float to IBM float value conversion

- 0of 0 votes
Build a function that takes one string and one regex expression in inputs and output true if the string matches the regex expression.

string: a-z

regex: a-z + * (where '*' matches 0 or more character and '+' matches one character)

- 0of 0 votes
Given a set of equalities and inequalities like A=B,B=C,F=J and A!=C, etc in two separate arrays (equalities[] and inequalities[]) and a method, separate that returns the two objects, e.g. separate(A=B) will return A and B, write an algorithm to find whether the entire set is consistent in constant time.

- 0of 0 votes
what all design patterns are used in designing a shopping cart and explain?

- 0of 0 votes
How do you normalize shopping cart tables?

- 0of 0 votes
Password storage rather than storing in DB.

- 0of 0 votes
How the tables are stored(different tables structure)

- 0of 0 votes
Design a shopping cart.

- 0of 0 votes
`while(scanf("%d,",&a)) { //store a as you wish to }`

Input given is : 1,2,3,4,5,6,7,8,9

`while(scanf("(%d,%d),",&a,&b)) { //store a and b as you wish to`

}

Input given is : (1,5),(8,11),(3,6),(10,20)

EXPLAIN INTERNAL WHOLE MECHANISM IN BOTH CASES

- 1of 1 vote
Given a binary tree, change the value in each node to sum of all the values in the nodes on the left side of the node.

Eg 1

/ \

2 3

3

/ \

2 6

solved this question using int* he asked me to do it without integer pointer.

- 0of 0 votes
An array contain 6 different numbers, only 1 number is repeated for 5 times. So now total 10 numbers in array, Find that duplicate number in 2 steps only?

- 0of 0 votes
You are given a mxn grid arr[][] and you stand at cell arr[p][q]. In 1 'move' you can either go up, down , left or right. Tell the probability that after taking 'k' moves, you are still inside the grid.

CODE:

(Can you point out any mistake)`#include <stdio.h> #include <stdlib.h> void traverse(int m, int n,int cur_x,int cur_y,int moves,int * in,int * tot) { if(moves==0) *tot = *tot+1; if(moves==0 && !(cur_x>=m||cur_y>=n||cur_x<0||cur_y<0)) *in = *in +1; traverse(m,n,cur_x,cur_y+1,moves-1,in,tot); traverse(m,n,cur_x+1,cur_y,moves-1,in,tot); traverse(m,n,cur_x,cur_y-1,moves-1,in,tot); traverse(m,n,cur_x-1,cur_y,moves-1,in,tot); } int main() { int m = 5, n = 5; int in=0,tot=0; int k,p,q; scanf("%d%d%d",&k,&p,&q); traverse(m,n,p,q,k,&in,&tot); printf("%d/%d ",in,tot); return 0; }`

- 1of 1 vote
Find the deepest node in a binary tree:

Example:

A

/ \

B C

/ \ / \

D E F G

\

H

Return Node ‘H’

- 1of 1 vote
Find the deepest node in a binary tree:

Example:

A

/ \

B C

/ \ / \

D E F G

\

H

Return Node ‘H’

- 1of 1 vote
Write a function to remove the duplicated characters from a string, and maintain the order of the characters.

ex. “abracadabra” ? “abrcd”

- -2of 2 votes
The boggle game - given a 2d array of characters

- 0of 0 votes
Evaluate a given mathematical expression, taking into consideration the BODMAS rule. The expression contains no brackets.

- 0of 0 votes
The Boggle game.