问题描述
假设我有一个节点链/列表:
(:node {uid:333})-->(:node {uid:102})-->(:node {uid:155})-->...
我想用另一个节点链替换一个或几个连续的节点。
(:node {uid:255})-->(:node {uid:107})
在我看来,要实现此目的的操作数量太多,无法在单个查询中进行。
1. input [255,107]
2. create the (255)-->(107)
3. find the place where to insert in the original chain
4. connect this node to (255)-->(107)
5. connect the tail-107 to the original chain (if it does not end)
6. delete the part to be replaced..
问题在于,如果不是单个查询,它将变得更加复杂。
您将如何执行此操作? (必须像字符串替换一样工作)
一种简化方法是找到链中的位置并使用索引。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)