Swift how to sort array of custom objects by property value

lets say we have a custom class named imageFile and this class contains two properties. class imageFile { var fileName = String() var fileID = Int() } lots of them stored in Array var images : Array = [] var aImage = imageFile() aImage.fileName = “image1.png” aImage.fileID = 101 images.append(aImage) aImage = imageFile() aImage.fileName = … Read more

Easy interview question got harder: given numbers 1..100, find the missing number(s) given exactly k are missing

I had an interesting job interview experience a while back. The question started really easy: Q1: We have a bag containing numbers 1, 2, 3, …, 100. Each number appears exactly once, so there are 100 numbers. Now one number is randomly picked out of the bag. Find the missing number. I’ve heard this interview … Read more