employer cover photo
employer logo
employer logo

Rockwell Automation

Is this your company?

Rockwell Automation Interview Question

Write a function to go through an array and count how many numbers are repeated and return this number.

Interview Answers

Anonymous

Jul 17, 2017

The other answer sort of works, but is absurdly inefficient and would probably lose you points. Iterate over each element in the array and check/store against a hash table. If the element is not present, insert it with the integer as the key and "false" as the value. If the element is present, and the value is "false," increment a counter and set the value to "true." If the element is present and the value is "true," do nothing.

1

Anonymous

Jun 9, 2017

use a nested for loop to go pull one number from the array and compare it to the rest of the array and so on.

2