Codility News: 7th Golden Award this year for me

Current Codility challenge is called Gallium 2018 and again I managed to make a solution that is awarded with a Golden Award. This one was a very interesting brain puzzle for me and it took me a white to figure it out.

Gallium2018Performance.png

The challenge ends tomorrow so if you like to try it by yourself these are the requirements.

Write a function:

class Solution { public int solution(int[] A); }

that, given an array of N positive integers, returns the maximum number of trailing zeros of the number obtained by multiplying three different elements from the array. Numbers are considered different if they are at different positions in the array.

For example, given A = [7, 15, 6, 20, 5, 10], the function should return 3 (you can obtain three trailing zeros by taking the product of numbers 15, 20 and 10 or 20, 5 and 10).

For another example, given A = [25, 10, 25, 10, 32], the function should return 4 (you can obtain four trailing zeros by taking the product of numbers 25, 25 and 32).

Assume that:

  • N is an integer within the range [3..100,000];
  • each element of array A is an integer within the range [1..1,000,000,000].

Complexity:

  • expected worst-case time complexity is O(N*log(max(A)));
  • expected worst-case space complexity is O(N) (not counting the storage required for input arguments).

Here is the award certificate that I’ve received.

Gallium2018GoldenAward.png

Good luck and happy coding,

J.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s