Created
September 25, 2014 01:28
-
-
Save hebertialmeida/da65f587b44c6aeef76e to your computer and use it in GitHub Desktop.
Given 2 arrays of integer (A and B) find the elements from A not belonging to B. Swift implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
let a = [1, 2, 3, 4, 5, 6, 7, 50, 30] | |
let b = [3, 10, 5, 6, 7, 8, 9, 51, 1] | |
var filter = [Int]() | |
for number in a { | |
if !contains(b, number) { | |
filter.append(number) | |
} | |
} | |
print(filter) | |
// Returns [2, 4, 50, 30] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment