(int v, int w)
| 123 | |
| 124 | // length of the shortest ancestral path between v and w; -1 if no such path |
| 125 | public int length(int v, int w) { |
| 126 | Helper helper = new Helper(); |
| 127 | helper.findSAP(v, w); |
| 128 | return helper.length; |
| 129 | } |
| 130 | |
| 131 | // a common ancestor of v and w that participates in a shortest ancestral path; -1 if no such path |
| 132 | public int ancestor(int v, int w) { |