我正在尝试使用链表打印字符串的反面。假设我的字符串是"World is full of good people“,它应该打印"people good of full is World” #include <iostream>
cout<<"Linked list after reverse is:\n";} 因此,如果字符
必须是O(n)和就地(空间复杂度为1)。下面的代码可以工作,但是有没有更简单或者更好的方法呢? if (this.getHead() == null) if (this.getHead().getNext() == null) //this method should reverse the order of this linked list in O(n) time
Node<E> prevNode = this.getHead().get