프로그래밍/코딩테스트 문제풀이
[Python] Hackerrank. Sherlock and the Valid String (Medium)
inspirit941
2020. 3. 11. 16:29
반응형
https://www.hackerrank.com/challenges/sherlock-and-valid-string/problem
Sherlock and the Valid String | HackerRank
Remove some characters from the string such that the new string's characters have the same frequency.
www.hackerrank.com
문자열의 개수를 셌을 때, 문자열 한 개만 지웠을 때 모든 문자열의 개수가 동일하면 YES, 아니면 NO를 출력하는 함수.
"문자열 한 개만 지웠을 때" YES가 가능하려면, 세 가지 경우가 있다.
1. 문자열 개수 자체가 1개인 경우
2. 가장 많이 등장한 문자열에서 1개를 제거했을 때, 모든 문자열 개수가 동일한 경우
3. 가장 적게 등장한 문자열에서 1개를 제거했을 때 모든 문자열 개수가 동일한 경우
반응형