# Java Solution NO Stack just Logic

• '''
public class Solution {
public int calculate(String s) {
int res = 0, sum = 0, multi = 0, sign = 1;
for(int i = 0; i < s.length(); i++){
char c = s.charAt(i);
if(Character.isDigit(c)){
sum = sum10 + (int)(c - '0');
}
else if(c == '+'){
if(sign < 2){
res += sign
sum;
}
else if(sign == 2){
res += multisum;
}
else if(sign == 3){
res += multi/sum;
}
sign = 1;
sum = 0;
multi = 0;
}
else if(c == '-'){
if(sign < 2){
res += sign
sum;
}
else if(sign == 2){
res += multisum;
}
else if(sign == 3){
res += multi/sum;
}
sign = -1;
sum = 0;
multi = 0;
}
else if(c == '
'){
if(sign < 2){
multi += signsum;
}
else if(sign == 2){
multi = sum;
}
else if(sign == 3){
multi /= sum;
}
sum = 0;
sign = 2;
}
else if(c == '/'){
if(sign < 2){
multi += sign
sum;
}
else if(sign == 2){
multi = sum;
}
else if(sign == 3){
multi /= sum;
}
sum = 0;
sign = 3;
}
}
if(sign < 2){
res += sign
sum;
}
else if(sign == 2){
res += multi
sum;
}
else if(sign == 3){
res += multi/sum;
}
return res;
}
}
'''

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