Stips Question
unknown
java
3 years ago
655 B
9
Indexable
Never
public static Node<Integer> isZogit(Node<Integer> L) { int firstSeq=0, tempSeq = 0; Node<Integer> first = L; Node<Integer> newLst,firstNewLst; if(first.getInfo()%2!=0) return null; while(L.getInfo()%2==0) { firstSeq++; L = L.getNext(); } newLst = new Node<Integer>(L.getInfo()); L=L.getNext(); firstNewLst = newLst; while(L!=null) { while(L!=null&&L.getInfo()%2==0) { tempSeq++; L=L.getNext(); } if(tempSeq!=firstSeq&&tempSeq>0) { return null; } tempSeq = 0; newLst.setNext(new Node<Integer>(L.getInfo())); newLst = newLst.getNext(); L = L.getNext(); } return firstNewLst; }