(SPOJ) Número Proibido - Solution
Link to the problem: http://br.spoj.com/problems/PROIBIDO/ The solution below keeps the forbidden numbers in a structure (HashSet). Then, for every query, we only need to check if the structure contains the numbers. As we are using a HashSet, this operation costs only O(1). import java.io.*; import java.util.*; class Main { public static long reader(BufferedReader br) throws NumberFormatException, IOException { long n; long resp = 0; while (true) { n = br.read(); if (n >= '0' && n <= '9') {...