Codility Fish (queue) programming challenge
I have some suggestions.


When declaring variable that has inheritance, uses the interface in the left declaration part; this will make the code easier to refactor.


Before 

ArrayDeque&lt;Fish&gt; safetyPool = new ArrayDeque&lt;Fish&gt;();
ArrayDeque&lt;Fish&gt; activePool = new ArrayDeque&lt;Fish&gt;();


After 

Deque&lt;Fish&gt; safetyPool = new ArrayDeque&lt;Fish&gt;();
Deque&lt;Fish&gt; activePool = new ArrayDeque&lt;Fish&gt;();



When using the diamond operators with variables, declared the type in the left side, the right one will become optional; since it's declared in the variable side.


Deque&lt;Fish&gt; safetyPool = new ArrayDeque&lt;&gt;();
Deque&lt;Fish&gt; activePool = new ArrayDeque&lt;&gt;();



To remove the Arrow Code in the while, I suggest that you read the blog post made by Jeff Atwood Flattening Arrow Code. In my opinion, it's the best way to get rid this kind of code.


The logic contained in the while can be refactored.

while (!activePool.isEmpty()) {
   Fish safeFish = safetyPool.peekLast();
   Fish swimmingFish = activePool.peekFirst();

   if (safeFish == null || safeFish.dir != 1 || safeFish.dir == swimmingFish.dir) {
      safetyPool.offer(activePool.pollFirst());
      continue;
   }

   if (safeFish.att &gt; swimmingFish.att) {
      activePool.removeFirst();
   } else {
      safetyPool.removeLast();
   }
}