K

@klesmana

Make Consecutive Array

Python
2 years ago
''' For a given array, count the number of missing elements required to make the array consecutive Example = [4,2,3,8] Output = solution(a) = 3 ''' def solution(a):

Count Increasing Elements

Python
2 years ago
''' For a given array [a] of integers, count the number elements that are larger than the previous element Example a = [19, 20, 20, 21, 23, 20, 25, 26] solution(a) = 5 ''' def solution(a):

First Non Repeating Character Test

Python
2 years ago
''' Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'. ''' def solution(s): return '_'

First Non Repeating Character

Python
2 years ago
''' Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'. ''' def solution(s): order = [] count = {} for c in s:

Average Query Time Test

Python
2 years ago
''' Array {data} contains arrays of elements of database query times [speed,isSuccess] isSuccess values are defined as follows: 1 = true, -1 = false, 0 = no data Calculate the average speed of successful queries '''

Average Query Time

Python
2 years ago
''' Array {data} contains arrays of elements of database query times [speed,isSuccess] isSuccess values are defined as follows: 1 = true, -1 = false, 0 = no data Calculate the average speed of succesful queries '''

Find area of polygon test

Python
2 years ago
''' A 1-interesting polygon is just a square with a side of length 1. An n-interesting polygon is obtained by taking the n - 1-interesting polygon and appending 1-interesting polygons to its rim, side by side. ''' def solution(n): return -1

Find area of polygon

Python
2 years ago
''' A 1-interesting polygon is just a square with a side of length 1. An n-interesting polygon is obtained by taking the n - 1-interesting polygon and appending 1-interesting polygons to its rim, side by side. ''' def solution(n): return n*

Find remaining paths test

Python
2 years ago
''' For given number of nodes(int) and paths(array) find remaining paths to have each pair of nodes connected. For nodes = 4 and paths = [[0, 1], [1, 2], [2, 0]], the output should be: solution(cities, roads) = [[0, 3], [1, 3], [2, 3]]. '''

Find remaining paths

Python
2 years ago
''' For given number of nodes(int) and paths(array) find remaining paths to have each pair of nodes connected. For nodes = 4 and paths = [[0, 1], [1, 2], [2, 0]], the output should be: solution(cities, roads) = [[0, 3], [1, 3], [2, 3]]. '''

Find first duplicate test

Python
2 years ago
''' Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the numbe

Find first duplicate

Python
2 years ago
''' Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number f