Search an element in a sorted and rotated array

An element in a sorted array can be found in O(log n) time via binary search. But suppose we rotate an ascending order sorted array at some pivot unknown to you beforehand. So for instance, [ 1, 2, 3 ...
Murat Sütunç
Published on Jan 4th, 2018

Multiples of 3 and 5

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Example Sol ...
Erkan Ercan
Published on Dec 27th, 2017

Lowercase Uppercase Convert

Text with a maximum of 100 characters will be given. Convert upper case letters to lower case letters and lower case letters to upper case letters. Example Solution Let string str equal to "coDeLAp ...
Hamit Can Uzunay
Published on Dec 26th, 2017

Divisibility Test

Write the function code that finds the average of the numbers divisible by 11 in the given array. Example Solution Let array arr equal to [ 10, 21, 246, 33, 47, 44, 99 ]. Divisions are: 33 , 44 , 9 ...
Hamit Can Uzunay
Published on Dec 24th, 2017

Divisible Rules

Write a program which will find all such numbers which are divisible by 2 but are not a multiple of 5, between 2500 and 4000 (both included). The numbers obtained should be printed in a comma-separa ...
Fatih Zor
Published on Dec 20th, 2017

Find largest number possible from set of given numbers

Given an array of integers, find the largest number possible. The numbers should be appended to each other in any order to form the largest number. Return this number in string format. Example Solut ...
Murat Sütunç
Published on Nov 16th, 2017

Maximum subarray problem

Given an array of integers, find the contiguous subarray within it which has the largest sum. Return the sum. Example Solution Let array arr equal to [ -2, 1, -3, 4, -1, 2, 1, -5, 4 ]. Subarray wit ...
Murat Sütunç
Published on Nov 16th, 2017

Find maximum difference between two elements in the array

Given an array of integers, find the maximum difference between two elements in the array such that the index of smaller element is also smaller than the index of the larger element. Return the diffe ...
Murat Sütunç
Published on Nov 16th, 2017

Find Longest Bitonic Subarray in an array

A sequence is called Bitonic if it is first increasing, then decreasing. In other words, an array arr[0..n-i] is Bitonic if there exists an index i where `0 = xi+1 >= … >= xn-1 A sequence, sorted in ...
Murat Sütunç
Published on Nov 16th, 2017

Replace each element of the array with product of every other element

Given an array of integers, replace each element of the array with the product of every other element in the array. Return the modified array. Example Solution Let array arr equal to [ 1, 2, 3, 4, ...
Murat Sütunç
Published on Nov 16th, 2017