Skip to content

vickhny/CodilityTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodilityTest

  1. Write a function solution that, given two integers A and B, returns the number of integers from the range [A..B](ends are included) which can be expressed as the product of two consecutive integers, that is X*(X+1), for some integer X and A <= B. Example: Given A = 6 and B = 20, the function should return 3 These integers are: 6 = 2 * 3, 12 = 3 * 4, and 20 = 4 * 5. Similarly, given A = 21 and B = 29, the function should return 0, There are no integers of the form X * (X + 1), for some integer X.

  2. You are given an implementation of a funtion: class Solution { public int solution(int[] A) } which accepts as input a non-empty zero-indexed array A consisting of N integers. The function works slowly on large input data and the goal is to optimize it so as to achieve better time and/or space complexity. The optimize function should return the same result as the given implementation for every input that satisfies the assumptions.

  3. You are given an array A of N positive integer and an integer K. Find the largest possible even sum of K elements at different positions in A. For Example given A = [4,9,8,2,6] and K=3, the largest even sum of three elements is 18. The three selected elements are A[0]=4, A[2]=8 and A[4]=6. Similarly for given A = [2,3,3,5,5] and K=3, the largest even sum of three elements is 12, because 5+5+2 = 12.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages