Input : 1 3 4 2 3 1
Output:
Element 1 : Count 2
Element 3 : Count 2
Element 4 : Count 1
Element 2 : Count 1
var count:Int
let tempArray = [1, 1,1, 4 ,1]
var index = 0
var fequency = [Int]()
for m in 0 ..< tempArray.count{
fequency.append(-1)
}
print(fequency)
for i in 0 ..< tempArray.count{
count = 1
for j in i + 1 ..< tempArray.count{
index = j
if tempArray[i] == tempArray[j]{
count = count + 1
fequency [j] = 0
print(fequency)
}
if fequency[i] != 0 {
fequency[i] = count
// print("frequency->",fequency)
}
}
print("\(tempArray[i]) occures at \(fequency[i]) times")
}