+ 2
This code is giving expected output but this code not passing the test cases in code coaches(Mathematics-hard)
4 Answers
+ 2
Oscar Panuko but the two private test cases are failing i do not know why
+ 1
The task has 2 inputs in separate lines. But your code reads input of single line.
For first input, Read line as text and convert to integer..
+ 1
When you take INT input you need to call sc.nextLine(); right after because the end of line is not stored in INT variable the second call sc.nextLine(); will have the end of line not the String input. Your Code doesn't pass all cases the problem says it could have multiple operations i'm guessing like (12+3*6) so you must do multiplication first then sum
I did this in order to verify you got the correct input and still doesn't pass all cases
import java.util.*;
public class Program
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int y=0,t=0;
String a1="";
sc.nextLine(); <âââââ
String b=sc.nextLine();
String d=b.trim();
String c[]=d.split(" ");
int c1[]=new int[c.length];
........ }
+ 1
Kailash Yandrapu The previous answers do explain why. Pls read them carefully.