# Validating O/p with wrong input - leetcode issue

• Below is my code :
class Solution {
public int calPoints(String[] ops) {

``````    for(int k = 0 ; k < ops.length ;k++){
System.out.println(ops[k]);
}

int resultSum = 0;
for(int i = 0; i < ops.length; i++){
if(checkInt(ops[i])){
//System.out.println("Output : "+ ops[i] + " Value : " + Integer.parseInt(ops[i]));
resultSum = resultSum + Integer.parseInt(ops[i]);
}else{
if(ops[i].equals("C")){
// remove last valid character and make it invalid
resultSum = resultSum - Integer.parseInt(val);
}else if(ops[i].equals("D")){
//add double amout to last valid points
resultSum = resultSum + (2 * Integer.parseInt(val));
}else if(ops[i].equals("+")){
//add last two valid sum into the result
Integer bb = Integer.parseInt(val)+Integer.parseInt(val2);
resultSum = resultSum + bb;
}
}

}
return resultSum;

}
public boolean checkInt(String val){
try{
Integer.parseInt(val);
return true;
}catch(Exception e){
return false;
}
}
``````

}

test case showing as input : ["35","-32","C","39","+","-48","C","5","88","-52","+","C","D","D","100","C","+","-74","53","59"]

Expected O/p : -397 (My code is give correct o/p for this test case.

Actual input which I am receiving

["57","D","-3","-58","D","77","+","C","+","+","38","78","-6","24","-46","+","31","20","D","-81"]

Can somebody tell me what to do in this situation? I am totally out of contest ....

• I have solve this problem. Thanks for looking into it

• How do you solve it ?
I have same issue in Java.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.