Professional Documents
Culture Documents
Hippo Video Assessment (Round 1)
Hippo Video Assessment (Round 1)
There are three types of matched pairs of brackets: [], {}, and ().
A matching pair of brackets is not balanced if the set of brackets it encloses are not matched.
For example, {[(])} is not balanced because the contents in between { and } are not balanced.
The pair of square brackets encloses a single, unbalanced opening bracket, (, and the pair of
parentheses encloses a single, unbalanced closing square bracket, ].
INPUT
[]{}()
OUTPUT
YES
If one or more filled cells are also connected, they form a region. Note that each cell in a
region is connected to at least one other cell in the region but is not necessarily directly
connected to all the other cells in the region.
Given an n x m matrix, find and print the number of cells in the largest region in the matrix.
n - no of rows
m - no of columns
Sample Input:
1 1 0 0
0 1 1 0
0 0 1 0
1 0 0 0
Sample Output:
For example, ABCD and ABDC have two children with maximum length 3, ABC and ABD.
They can be formed by eliminating either the D or C from both strings. Note that we will not
consider ABCD as a common child because we can't rearrange characters and ABCD is not
equal to ABDC
Sample Input:
HARRY
SALLY
Sample Output:
2
Ques4. Stock
You have been given stock prices for next N days. Find out the maximum profit that can be
obtained by buying and selling the stocks.
Conditions:
You can buy and sell multiple times, but cannot hold more than 1 stock at a time.
You can only perform a single transaction on a day. i.e. can only either buy or sell on a single
day
For example:
5146784379
Max benefit:
Total: (8 - 1) + (9 - 3) = 13
INPUT
Sample:
10
5146784379
OUTPUT
13