(Node head, int key)
| 121 | } |
| 122 | |
| 123 | public int searchHelper(Node head, int key) { |
| 124 | if(head == null) { |
| 125 | return -1; |
| 126 | } |
| 127 | if(head.data == key) { |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | int idx = searchHelper(head.next, key); |
| 132 | if(idx == -1) { |
| 133 | return idx; |
| 134 | } |
| 135 | return idx+1; |
| 136 | } |
| 137 | |
| 138 | public void reverse() { |
| 139 | Node prev = null; |