## C Interview Questions

- 1of 1 vote
You have given height array of array. Generate the original array.

Input: [6,3,0,2,2,0,0]

Output : [ 1,5,7,3,2,6,4]

A[i] value in input array is the number of greater element on right side.

- 0of 0 votes
How to print nested array ?

Input : [1, 5, 8, [9, 10, 24, 20, [39, 48], 89], 105, 99]

Output : 1, 5, 8, 9, 10, 24, 20, 39, 48, 89, 105, 99.

Which data structure you will use to store the values?

- 0of 0 votes
`Insert a number into an array of sorted intervals. For example, [1,4], [6,8], after insert 5, return [1,8]. class Interval{ int start; int end; public Interval(int start, int end){ this.start = start; this.end = end; } } class Solution{ public List<Interval> insert(List<Interval> list, int val){ } }`

- 0of 0 votes
Write code to find unmatched parentheses and return it in the below format:

((a) -> -10a1

(a)) -> 0a1-1

(((abc))((d))))) -> 000abc1100d111-1-1

- 0of 0 votes
give a bunch of job dependency, such as A-> B, A -> C, B-> D, and so on, implement two interfaces.

The first one is get_next_stage, which returns jobs in parallel for the next phase. The second is job_done, which tells you which job completed.

- 0of 0 votes
Given an array of sorted integers and find the closest value to the given number. Array may contain duplicate values and negative numbers.

Example : Array : 2,5,6,7,8,8,9

Target number : 5

Output : 5

Target number : 11

Output : 9

Target Number : 4

Output : 5

- 0of 0 votes
Suppose you have an input character stream (StreamReader) and you have a list of pattens like ABCAS, ASGKT. KHTSD etc. You need to read the stream one by one character and you need to keep count on number of each pattern found so far and when EOF occures just print all the patterns along with count.

Example:

Input String: 011100010

Pattern 1: 011

Pattern 2: 010

Output:

011 => 1

010 => 1

- 0of 0 votes
Give a list of the company's Mergers and Acquisitions relationships, for example

[

["baidu", "ofo"],

["mobike", "alibaba"],

]

Said baidu acquired ofo, mobike acquired Alibaba.

Seeking the longest of a M & A chain. No cycle

- -1of 1 vote
Get fast and reliable technical support for your any type of issue related to facebook. Facebook is the largest used social platform, many time users got some technical issue that are not solvable from their end. In this situation they need help from technical experts of facebook. By dialing facebook contact number 1 866 324 3042 toll-free, you will get connected with the most reputed team of technical experts.

For more info, visit at http://www.facebookhelp.us

- 0of 0 votes
You are given a rooted tree. The tree is not necessarily binary. The tree contains N nodes, labeled 1 to N. You are given the tree in the form of an array P[1..N] of size N. P[i] denotes label of the parent of node labeled i. For clarity, you may assume that the tree satisfies the following conditions.

The root of the tree is labeled 1. Hence P[1] is set to 0.

The parent of node T will always have a label less than T. Hence P[i] < i will always be true.

All nodes contain a mutable value (or, more simply, a variable), which is initially set to 0.

You are asked to perform several operations of the following type

ADD X Y: add Y to the value at node X.

ADDUP X Y: add Y to the value at node X. Then, add Y to the value at P[X] (i.e. the parent of X). The, add Y to the value at P[P[X]] (i.e. the parent of P[X]).. and so on, till you add Y to the value at root.

After you have performed all the given operations, you are asked to answer several queries of the following type

VAL X: print the value at node X.

VALTREE X: print the sum of values at all nodes in the subtree rooted at X (including X).

Input

The first line of input contains the number T, the number of test cases. Then follows the description of T test cases. The first line of each test case contains the numbers N, M and Q respectively (separated by single space character). N depicts the number of nodes. M depicts the number of operations you must perform. Q depicts the number of queries you must answer.

The next N lines contain a number each, depicting the array P[1..N]. Of course the number on the first such line is always 0.

The next M lines contain description of the respective operation. An operation will be either "ADD X Y" or "ADDUP X Y" (without the quotes). Please refer to the problem statement and sample I/O explanation for clarity on the meaning of the operations.

After the operations, the next Q lines contain description of the queries. A query will be either "VAL X" or "VALTREE X" (without the quotes). Please refer to the problem statement and sample I/O explanation for clarity on the meaning of the queries.

Output

Print the result of each query on a line by itself. Since the answer for some queries may be too large, please print the result modulo 1,000,000,007. Do not print any blank lines between test cases.

Constraints

1 ≤ T ≤ 10

1 ≤ N ≤ 50000

1 ≤ M ≤ 50000

1 ≤ Q ≤ 50000

1 ≤ X ≤ N

1 ≤ Y ≤ 50000

The input file will be smaller than 2 MB.

Sample Input

2

5 5 3

0

1

1

1

3

ADD 1 10

ADD 2 20

ADD 3 30

ADD 4 40

ADDUP 5 50

VAL 3

VALTREE 3

VALTREE 1

7 4 5

0

1

2

2

2

1

2

ADD 6 76

ADDUP 1 49

ADD 4 48

ADDUP 2 59

VALTREE 1

VALTREE 5

VAL 5

VALTREE 2

VAL 2

Sample Output

80

130

250

291

0

0

107

59

Explanation

In the first sample case, at the end of app the operations, the values at each of the nodes is as follows

1: 60

2: 20

3: 80

4: 40

5: 50

Also, the sum of the values of all the nodes in the subtree rooted at each of the nodes is as follows

1: 250

2: 20

3: 130

4: 40

5: 50

- 0of 0 votes
You are given a grid with 3 rows and N columns. Each cell in the grid contains the value 0 initially. You perform several operations of the following type on the grid

Pick a row, say r. Pick a start column and end column, say s and e. Of course 1 ≤ s ≤ e ≤ N. Now, set all values in the grid in row r, from column s to column e to 1.

After you perform all the operations, you wish to find subgrids in this grid (or rectangles, if you please) which contain only 1s. Most importantly, you wish to find the rectangle that has the largest area. Print the area of this rectangle.

Input

The first line of input contains a number T, the number of test cases. The first line of each test case contains the number N and M respectively, separated by a single space. N is the number of columns in the grid. M is the number of operations you perform on the grid. Each of the next M lines contain three integers R, C1 and C2 respectively to describe the operation. R is the row in which the operation is performed. C1 and C2 are the start and end columns respectively. You may assume that 1 ≤ C1 ≤ C2 ≤ N.

- 0of 0 votes
Consider a string with brackets for eg: [ytu[78]][12]. If the start index of the open bracket is given, find the index of the closing bracket.

- 0of 0 votes
Implement zad-off-chu sequence for LTE eNodeB in c language?

- 0of 0 votes
determine whether a number is the sum of two squares, such as 17 = 16 +1

- 0of 0 votes
`Give a matrix, for example 1 0 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 Find if there is a rectangle in the matrix, all four corners are 1 For the example, there is only one rectangle, that is 1 0 1 0 1 0 1 0 1`

- -1of 1 vote
How to use Facebook Messenger?

- 0of 0 votes
class DirectedGraphNode {

int label;

List<DirectedGraphNode> neighbors;

DirectedGraphNode(int x) {

label = x;

neighbors = new ArrayList<>();

}

}

check if there is a cycle in a directed graph, if there is a cycle, remove all the cycles

- 0of 0 votes
How to fix Dell Printer Technical Issues?

- 0of 0 votes
How to Recover Forgotten Sbcglobal Mail Password?

- -1of 1 vote
Sachin wants to buy a laptop for programming. he plans on buying a laptop whose price is made of digits 4 and 7 only. The number of 4s and 7s in the price should be equal. You are given laptop brand names and their prices. Find and print the name of the laptop brand that satisfies the above criteria. If there are multiple brands that meet the criteria, print the name of the one with the minimum price. If none of the laptops meet the criteria print -1.

For example, if Sharon has a choice between laptops 'BestBook' priced at 444777 and 'LapBook' priced at 7744, the solution should indicate ideal choice to be 'LapBook'. Although both 'BestBook' and 'LapBook' have equal number of 4s and 7s in the price, 'LapBook' is priced lower which makes it the right choice for Sharon.

- 1of 1 vote
You are given a binary tree and a function shouldBeErased(node to check whether a node should be erased. Erase all nodes that should be erased in the binary tree and return the resulting forest in the form of an array of every root node.

Follow up:

What if this is a Binary Search Tree? (In this case you are given a list of nodes that should be erased instead of the function.) Does it make the problem simpler or more complicated or just the same?

- 0of 0 votes
given a string and a segmentation length k

For example:

"This is a good day" k = 10

Cut into:

"This (1/4)"

"is a (2/4)"

"good (3/4)"

"day (4/4)"

Each line followed by a suffix in the form of (i/n) has 10 chars including space (except for the last line), return the minimum cut required, for the example, just return 4.

- 0of 0 votes
trie search, Search Return all words that match the wildcard *

such as

add ("car")

add ("caw")

add ("cauw")

search ("c*w") returns "caw" and "cauw".

- 0of 0 votes
Given two sorted linked lists, how can you combine them into one big sorted list? Do not create additional nodes.

- 0of 0 votes
There is going to be a sale during this month. You are interested in a particular item and you found that different Vendors have different prices during different time periods. You collected the following information:

`Vendor => (start date, end date, price) both sides inclusive A => (1, 5, $20) B => (3, 6, $15) C => (2, 8, $25) D => (7, 12, $18) E => (1, 31, $22)`

As you can see, there are conflicting entries. You need to print out a non-conflicting schedule of prices, taking the best price from each period:

e.g.

(1, 2, $20), (3, 6, $15), (7, 12, $18), (13, 31, $22)

- 0of 0 votes
Given a list of currency exchange rates like this:

EUR/USD => 1.2

USD/GBP => 0.75

GBP/AUD => 1.7

AUD/JPY => 90

GBP/JPY => 150

JPY/INR => 0.6

write a method`double convert(String sourceCurrency, double amount, String destCurrency);`

For example, convert(EUR, 100, INR)

The method should minimize the number of intermediate conversions.

- 0of 0 votes
You are given an arbitrary number of graphs using sets such as {a,b,c,d,a}, {a,b,a}, {e,f,g,h,e}... etc. Assume each element at position x_i in a set has a directed edge to x_{i+1}. so a-->b, b-->c etc. Write a program that selects a subset of at mot k vertices that contains at least one vertex from every directed cycle in the graph.

- 0of 0 votes
Write a program that always produces a two-way Euler tour that can be drawn such as it does not cross itself at any vertex.

- 0of 0 votes
let's say you're given an arbitrary list of relations r1 and r2 from objects in a set of arbitrary size. find the size of th largest subset with the property that no two are related. for e.g., given set S = {a,b,c,d,e,f} and relations {a,d}, {b,c}, {a,c}, {a,e}, find the subset of S such that no two a connected.

- -2of 2 votes
There was given total physical energy H and total distance D. Five pace information speed and corresponding physical energy was given. Find the minimum time that is required in order to complete total distance D making sure that some of the physical energy does not exceed H