|A road has been laid out so that it consists of segments, each of which
runs either North-South or East-West. We will say that one segment
"touches" another segment if the two segments have a common point, other than
the common point between two sequential segments in the path. We want to check
the surveyor's data to make sure that it represents a simple path -- specifically
one in which no two segments touch.
We are given a String direction and a int length giving the surveyor's data
for each segment of the road. The i-th character of
direction tells the direction ('N','E','S', or 'W') of the i-th segment, and
the i-th element of length tells the length of that segment.
Create a class SimplePath that contains a method trouble that is given direction
and length and returns the zero-based index of the lowest-indexed segment that touches
another segment. If no two
segments touch, return -1.