Commit 89971454 authored by Fokion Zervoudakis's avatar Fokion Zervoudakis

Use explicit types.

parent 394f701c
package interview;
import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
......@@ -18,9 +19,9 @@ class SlidingMax {
@return the maximum values of each sub-array of length {@code k}
*/
List<Integer> getMax(int[] A, int k) {
var L = new ArrayList<Integer>();
var Q = new LinkedList<Integer>();
for (var i = 0; i < A.length; i++) {
List<Integer> L = new ArrayList<>();
Deque<Integer> Q = new LinkedList<>();
for (int i = 0; i < A.length; i++) {
if ((!Q.isEmpty()) && Q.peekFirst() <= i - k) {
Q.removeFirst();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment