Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

size = len(list of list)

x = [1,1,2,3,3,3,4,4,5,5,6,6,7,7,7] // ===>>> (flatmap(list of list).sort)


x_size = len(x)
temp = []
count_f = 1
count_b = 1
front = x[1]
back = x[x_size - 1]
mid = len(x_size ) div 2

//loop from 1 to mid


for(i = 1; i < mid; i++){

if (front == x[i]) {
count_f += 1
if (count_f == (size)) {
temp.add(x[i])

count_f = 1
}
}
}else{
count = 1
}
front = x[i]

if (back == x[x_size - 1 - i]) {


count_b += 1
if (count_b == (size)) {
temp.add(x[x_size - i])
count_b = 1

}
}else{
count_b = 1
}
back = x[i]
}

if x_size mod 2 == 0 {
if (front == back) and (count_f + count_b == size) {
temp.add(x(mid))

}
}else{
if(front == back) and (front == x[mid + 1]) {
if (count_f+count_b + 1 == size){
temp.add(x[mid])
}
}else {
if(front != back){
if(front == x[mid]) and (count_f + 1 == size){
temp.add(front)
}else if (back == x[mid]) and (count_b + 1 == size){
temp.add(back)
}
}
}

You might also like