Given array of integers, remove each kth element from it.
For inputArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
and k = 3
, the output should be
extractEachKth(inputArray, k) = [1, 2, 4, 5, 7, 8, 10]
.
- [time limit] 4000ms (py3)
Given an array of equal-length strings, check if it is possible to rearrange the strings in such a way that after the rearrangement the strings at consecutive positions would differ by exactly one character.
For inputArray = ["aba", "bbb", "bab"]
, the output should be
stringsRearrangement(inputArray) = false
;
All rearrangements don't satisfy the description condition.
For inputArray = ["ab", "bb", "aa"]
, the output should be
Given a sorted array of integers a
, find such an integer x
that the value of
abs(a[0] - x) + abs(a[1] - x) + ... + abs(a[a.length - 1] - x)
is the smallest possible (here abs
denotes the absolute value).
If there are several possible answers, output the smallest one.
For a = [2, 4, 7]
, the output should be
You have deposited a specific amount of dollars into your bank account. Each year your balance increases at the same growth rate
. Find out how long it would take for your balance to pass a specific threshold
with the assumption that you don't make any additional deposits.
For deposit = 100
, rate = 20
and threshold = 170
, the output should be
depositProfit(deposit, rate, threshold) = 3
.
Each year the amount of money on your account increases by 20%
. It means that throughout the years your balance would be:
100
;Consider integer numbers from 0
to n - 1
written down along the circle in such a way that the distance between any two neighbouring numbers is equal (note that 0
and n - 1
are neighbouring, too).
Given n
and firstNumber
, find the number which is written in the radially opposite position to firstNumber
.
For n = 10
and firstNumber = 2
, the output should be
circleOfNumbers(n, firstNumber) = 7
.
Given two cells on the standard chess board, determine whether they have the same color or not.
For cell1 = "A1"
and cell2 = "C3"
, the output should be
chessBoardCellColor(cell1, cell2) = true
.
For cell1 = "A1"
and cell2 = "H3"
, the output should be
chessBoardCellColor(cell1, cell2) = false
.
Correct variable names consist only of Latin letters, digits and underscores and they can't start with a digit.
Check if the given string is a correct variable name.
For name = "var_1__Int"
, the output should be
variableName(name) = true
;
For name = "qq-q"
, the output should be
variableName(name) = false
;
Given an array of integers, replace all the occurrences of elemToReplace with substitutionElem.
For inputArray = [1, 2, 1]
, elemToReplace = 1
and substitutionElem = 3
, the output should be
arrayReplace(inputArray, elemToReplace, substitutionElem) = [3, 2, 3]
.