Hi there,
I have the following problem,
I want to get the pair of given sum by using higher order functions. I am able to do this using iterative approach. Can someone help me to solve the problem using higher order function.
let array = [1,2,3,4]
let givenSum = 5
for i in 0..<array.count {
let j = i + 1
for j in j..<array.count {
if array[i] + array[j] == givenNum {
print("Pair : \(array[i]),\(array[j])")
}
}
}
The output is [2,3]
Any help is appreciated.
Thank you
Post
Replies
Boosts
Views
Activity
Is it possible to get the camera zoom level on various device models in iPhone like in builtin camera programmatically example 0.5x, 1x, 2x buttons etc?
Hi Everyone,
Does storekit2 supports reedeming promotional offer codes and discounts?