如何在2D LinkedList
的底部添加一行O(1)
?我一直在运行循环,但我必须在O(1)中实现它。可以帮忙吗?在2D链接列表末尾添加一条线
[0,0,0,0]
[0,0,0,0]
[0,0,0,0]
[0,0,0,0]
.........//I want to add one more line here <-----
LinkedList<LinkedList<T>> myList = new LinkedList<LinkedList<T>>();
public void addLastLine(){
LinkedList<T> rowLine = new LinkedList<T>();
this.lastRow += 1;
myList.add(lastRow, rowLine);
for(int col = 0; col <= origCol; col++){
rowLine.add(col, this.element);
}
}
你想添加什么行? –
@DhiwaTdG,我想在O(1) –