View Code of Problem 134

import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in =new Scanner(System.in);
		while(in.hasNext()) {
			int n = in.nextInt();
			int[] num = new int[n];
			for(int i =0;i<n;i++) {
				num[i]=in.nextInt();
			}
			int q = in.nextInt();
			for(int i =0;i<q;i++) {
				int l = in.nextInt()-1;
				int r = in.nextInt()-1;
				ArrayList <Integer> al = new ArrayList <Integer>();
				for(int j =l;j<=r;j++) {
					al.add(num[j]);
				}
				Collections.sort(al);
				System.out.print(al.get(0));
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 134