Sunday, 27 December 2015

Kata Day 31: Array comparator:


Problem Description: You have two arrays in this kata, every array contain only unique elements. Your task is to calculate number of elements in first array which also are in second array.

Level:7kyu

Link to Kata: Array comparator

This was a simple Kata. We have to find intersection of one array compared to another array. I initialized a variable "count" equal to 0. I looped through the given array and it can be any array as both the given arrays are of same length. Then I checked index of every element of first array in the second array and if the index returned was not equal to -1 then I incremented the count by 1.

In the end once the loop is finished I output the value of count as the solution to this Kata.

Here is a link to the code: Kata Day 31

Please mention your suggestions or your doubts in the comment below.

I finished 1 month of coding!!

Happy coding. :)

No comments:

Post a Comment