Check if two integer iterators have the maximum distance of one

Given the interface IntIterator defined in the following, implement the method isDistanceZeroOrOne(IntIterator a, IntIterator b) to return if the distance between a and b is at most one, where the distance is defined as the minimum number of modifications to make them equal to each other. Modifications can be: 1) change an int in a. 2) insert an int to a. 3) remove an int from a. For example, the method should return true for 1, 2, 2 and 1, 3, 2, 2.

Implement an H() method and an O() method to produce a water molecular

Both methods are to be called by multiple threads. Each thread calling either method becomes blocking and when one thread finds that there are already at least two threads calling H() and at least one thread calling O(), let two threads calling H() and one thread calling O() resume from blocking in order to produce a water molecular.

Paint a row of houses with the minimum cost

There are a row of houses. Each house can be painted with three colors: red, blue and green. The cost of painting each house with a certain color is different. No two adjacent houses have the same color. Paint the houses with the minimum cost.

Find all the words in a list that are next to a given word

There is a list of four-letter words, such as aahs, aals, abas, abba, etc. Given an arbitrary four-letter word, find all the words in the list that are next to the given word, i.e., words that can be the same as the given word with exactly one letter changed. Example: given puma, the result could be duma, pima, puja, pula, pump, puna, pupa.