로딩
요청 처리 중입니다...

JAVA_LeetCode 3707_Equal Score Substrings

 JAVA_LeetCode 3707_Equal Score Substrings

JAVA_LeetCode 3707_Equal Score Substrings 풀이 class Solution { public boolean scoreBalance(String s) { int tot = 0, left = 0; for(char c : s.toCharArray()) tot += (c - 'a' + 1); for(int i = 0; i < s.length() - 1; i++){ left += (s.charAt(i) - 'a' + 1); if(left * 2 == tot) return true; } return false; } } 총합 중 특정 지점 기준으로 좌우 합계가 같은 수를 찾는 문제 특정 지점 기준, 좌우 합계가 같다는 보장이 없음 지점 상관없이 구하는 방식 한쪽 합계(left)를 구하고 left * 2 = 총합인경우 → true 한쪽 합계(left)를 구하고 left * 2 ≠ 총합인경우 → false * 출처 https://leetcode.com/problems/...