Find the elements present in Array or not?
Code
func findSequence(_ list: [Int]) -> Bool {
let sequence = [1, 2, 3]
// Check if the sequence exists in the current list
var foundSequence = true
for element in sequence {
if !list.contains(element) {
foundSequence = false
break
}
}
if foundSequence {
return true
}
return false
}