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

From Paycheck to Prosperity: A Real-Life Blueprint for Financial Success

Introduction Are you stuck in the paycheck-to-paycheck cycle? Are you dreaming of financial freedom but unsure where to begin? This isn'...