@skylinebaby It should be about O(k*n).

See below the execution for n=5 and k=4:

initially: [[1], [2]]

For i = 2,

temp list: [1]

m: from 2 to 3

after adding elements: [[1, 2], [1, 3]]

temp list: [2]

m: from 3 to 3

after adding elements: [[1, 2], [1, 3], [2, 3]]

For i = 3,

temp list: [1, 2]

m: from 3 to 4

after adding elements: [[1, 2, 3], [1, 2, 4]]

temp list: [1, 3]

m: from 4 to 4

after adding elements: [[1, 2, 3], [1, 2, 4], [1, 3, 4]]

temp list: [2, 3]

m: from 4 to 4

after adding elements: [[1, 2, 3], [1, 2, 4], [1, 3, 4], [2, 3, 4]]

For i = 4,

temp list: [1, 2, 3]

m: from 4 to 5

after adding elements: [[1, 2, 3, 4], [1, 2, 3, 5]]

temp list: [1, 2, 4]

m: from 5 to 5

after adding elements: [[1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 4, 5]]

temp list: [1, 3, 4]

m: from 5 to 5

after adding elements: [[1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 4, 5], [1, 3, 4, 5]]

temp list: [2, 3, 4]

m: from 5 to 5

after adding elements: [[1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5]]