Sei sulla pagina 1di 2

1. You are given a target number, and an array of integers.

Your task is to find two numbers


from the array which when summed up are equal to target number. You can not use the
same element twice. If there is no solution, you should return -1.
The input is given in two rows:
 1st row is the target integer
 2nd row is the array of integers separated by a space (see the sample input below)
The output should be the index of two elements separated by space
and ordered ascending (see the sample output below). Or if there is no solution, output
should be -1.
You can assume that:
 the array is not empty
 the array size does not exceed 10000 elements.
 the array contains only integers

2. You are given a string value. Write a code that will reverse the vowels in a string and return
the resulting string.
For example:
 for input of "ingsoftware" the result would be "engsaftwori"
 for input of "practice" the result would be "prectica"
You can assume that:
 input is not null or empty string
 input is not longer than 50 characters
 input is provided in all lower cases (you can ignore letter case in the string)
 character 'r' is not a vowel.

3. You are given an array of non-negative integers. Each number represents the elevation
of single point in an imaginary 2-D elevation map. Your task is to calculate how many units
of water could be contained on given map, if we assume that 1 unit of height holds 1 unit
of water.
The input is provided in single row as the array of integers separated by a space
You can assume that:

 the array has only positive integers


 the array is not empty
 the array size does not exceed 10000 elements

Below are examples that can help you illustrate the problem
 Image A, represents the example array with visualized elevation (each unit of
height represented with single 'x' character)
 Image B represents the maximum number of water units that can be "cought" (each
unit of water represented with 'o' character)

4. You are given a square board of 'x' and 'o' characters. Your task is to flip all captured 'o'
characters.
 You flip 'o' characters by marking them as 'x'.
 An 'o' character is considered captured if it or any surrounding 'o' characters are
surrounded on all 4 sides by 'x' (and do not have direct connection to the outer
border). If any of the 'o' characters grouped together have connection to the outer
border, than none of those 'o' characters is captured.
The input is provided in multiple rows:
 first row is the board size n (the board is squared)
 n rows each representing one row of board in a format of x/o characters delimited
by space (see input example)
The output should be the new captured board. Single line per board row in a format of x/o
characters delimited by space (see output example).
You can assume that:
 the size n of the board is between 2 and 20
 the board contains only 'x' or 'o' characters
 there is at least one 'o' character and at least one 'x' character
Note that sample input/output is display only and shows incorrectly with empty
lines between each row. The actual results and inputs do not have empty lines
between rows

Potrebbero piacerti anche