letarr=[{code:'abcd',pcode:'abc',},{code:'abc',pcode:'ab'},{code:'ab',pcode:'a'}]letobj={code:'abcd',pcode:'abc',}如上所示,arr里面的數(shù)據(jù)都是有上下關(guān)系的,現(xiàn)在希望根據(jù)obj在arr中依次查找父級,比如obj的父應(yīng)該是{code:'abc',pcode:'ab'},然后繼續(xù)查找{code:'abc',pcode:'ab'}的父數(shù)據(jù)應(yīng)為{code:'ab',pcode:'a'},以此類推,最后將符合條件的數(shù)據(jù)存放到一個數(shù)組里面,求一個遞歸的解法。
萌新求教!平行結(jié)構(gòu)數(shù)據(jù)的一些處理
慕森王
2019-06-09 09:01:16