public static int followPointers(int[] locations)
	{
		if (null == locations || locations.length < 1)
			return 0;
		if (locations.length == 1 && locations[0] == 0) // short cut for odd case
			return 1;
		
		int countCycle = 0;
		
		ArrayList<Integer> visitedLocations = new ArrayList<Integer>(locations.length);

		for (int pos = 0; pos < locations.length; pos++)
		{
			int loc = locations[pos];
			if (visitedLocations.contains(pos))
				continue;
			visitedLocations.add(pos);
			if (loc != -1 && findRoute(pos, locations, loc, visitedLocations))
			{
				countCycle++;
			}
		}
		
		return countCycle;
	}