6 kyu

Arrays Similar

3,149 of 3,711jgable

Description:

Write a function that determines whether the passed in sequences are similar. Similar means they contain the same elements, and the same number of occurrences of elements.

var arr1 = [1, 2, 2, 3, 4],
    arr2 = [2, 1, 2, 4, 3],
    arr3 = [1, 2, 3, 4],
    arr4 = [1, 2, 3, "4"]
arr1 = [1, 2, 2, 3, 4]
arr2 = [2, 1, 2, 4, 3]
arr3 = [1, 2, 3, 4]
arr4 = [1, 2, 3, "4"]
arraysSimilar(arr1, arr2); // Should equal true
arraysSimilar(arr2, arr3); // Should equal false
arraysSimilar(arr3, arr4); // Should equal false
arrays_similar(arr1, arr2) # Should equal true
arrays_similar(arr2, arr3) # Should equal false
arrays_similar(arr3, arr4) # Should equal false
Arrays
Algorithms

Stats:

CreatedJul 17, 2013
PublishedJul 31, 2013
Warriors Trained4999
Total Skips336
Total Code Submissions16689
Total Times Completed3711
JavaScript Completions3149
CoffeeScript Completions152
Python Completions423
Total Stars43
% of votes with a positive feedback rating93% of 486
Total "Very Satisfied" Votes425
Total "Somewhat Satisfied" Votes52
Total "Not Satisfied" Votes9
Ad
Contributors
  • jgable Avatar
  • albertogcmr Avatar
  • Kacarott Avatar
  • farhanaditya Avatar
  • avermakov Avatar
Ad