/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new
InputStreamReader(System.in));
}
int nextInt() {
try{
return Integer.parseInt(next());
}catch(NullPointerException e){
return 0;
}
}
long nextLong() {
return Long.parseLong(next());
}
int[] arry(int l) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
int[] arr=new int[l];
for (int i = 0; i < l; ++i) {
arr[i] = Integer.parseInt(st.nextToken());
}
return arr;
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
}
public static void main (String[] args) throws java.lang.Exception
{
FastReader fr=new FastReader();
int t=fr.nextInt();
while(t!=0){
String p=fr.next();
int m=Integer.parseInt(p);
for(int i=0;i<p.length();i++){
StringBuilder sb=new StringBuilder(p);
int tp=Integer.parseInt(sb.deleteCharAt(i).toString());
if(tp<m&&tp!=0){m=tp;}
}
System.out.println(m);
t--;
}
}
}
This is my first code on code chef.
Worked fine with custom inputs. but the code is note accepted.
@suman_18733097
Then will my code be accepted if I initialize the variable m to the maximum possible value. I’m asking this because I don’t know in what test case my code can go wrong.
My solution gives 0 and your solution gives 1 as the answer. I think 0 is the answer for this test case, since it was not mentioned Explicitly, that answer should not be 0 .