我有一个格式如下的列表列表。
[[1,3],[2,4],[3,1],[4,0],[5,1],[6,0],[7,1],[8,0],[ 9,1],[10,0],[11,3],[12,1],[13,0],[14,1],[15,0],[16,1],[17, 0],[18,4],[19,1],[20,0],[21,1],[22,0],[23,1],[24,2],[25,0] ,[26,0],[27,1],[28,0]......]
或以图形方式,我的输入列表是:
[1,3]
[2,4]
[3,1]
[4,0]
[5,1]
[6,0]
[7,1]
[8,0]
[9,1]
[10,0]
[11,3]
[12,1]
[13,0]
[14,1]
[15,0]
[16,1]
[17,0]
[18,4]
[19,1]
[20,0]
[21,1]
[22,0]
[23,1]
[24,2]
[25,0]
[26,0]
[27,1]
[28,0]
在上面的输入中,列表的第一个值(零位置)是项目序列(你可以从上到下看到它们),第二个值是它拥有的孩子的数量!
我希望我的输出在第三个值(第二个位置)中我希望它的父级如下例所示......
我想得到如下输出: [[1,3,0],[2,4,1],[3,1,2],[4,0,3],[5,1,2],[ 6,0,5],[7,1,2],[8,0,7],[9,1,2],[10,0,9],[11,3,1],[12, 1,11],[13,0,12],[14,1,11],[15,0,14],[16,1,11],[17,0,16],[18,4, 1],[19,1,18],[20,0,19],[21,1,18],[22,0,21],[23,1,18],[24,2,23] ,[25,0,24],[26,0,24],[27,1,18],[28,0,27].....]
以图形方式所需的输出:
[1,3,0]
[2,4,1]
[3,1,2]
[4,0,3]
[5,1,2]
[6,0,5]
[7,1,2]
[8,0,7]
[9,1,2]
[10,0,9]
[11,3,1]
[12,1,11]
[13,0,12]
[14,1,11]
[15,0,14]
[16,1,11]
[17,0,16]
[18,4,1]
[19,1,18]
[20,0,19]
[21,1,18]
[22,0,21]
[23,1,18]
[24,2,23]
[25,0,24]
[26,0,24]
[27,1,18]
[28,0,27]
怎么解决?