Let's say I have a Python list that looks like this:
list = [ a, b, c, d]
I am looking for the most efficient execution method to get this:
list = [ a, a, a, a, b, b, b, c, c, d ]
So, if the list contains N elements, then the first element is cloned N-1 times, the second element N-2 times, etc ... the last element is cloned NN times or 0 times. Any suggestions on how to do this effectively on large lists.
source
share