Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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:
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