Sunday, May 30, 2021

codeforces 282A Solution A. Bit++ (codeforces 282A) (rank 800*)

 282A. Bit++


Problem Link: https://codeforces.com/problemset/problem/282/A


Solution 1:

import java.util.*;

public class A282 {
    public static Scanner scn = new Scanner(System.in);

    public static int finalAns(int n){
        String str = "";
        int ans = 0;
        for(int i=0;i<n;i++){
            str=scn.next();

            if(str.charAt(0)=='+' || str.charAt(2)=='+'ans++;
            else ans--;
        }

        return ans;
    }

    public static void main(String[] argv){
        int n = scn.nextInt();
        System.out.println(finalAns(n));
    }
}

No comments:

Post a Comment

Thanks

Climate Crisis and Innovation: Navigating Earth's Future

Climate Change: Recent Events and Technological Solutions 1. The Escalating Climate Crisis The climate crisis has intensified in recent year...