Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
풀이
저는 이 문제를 보고 어떻게 풀어야할지 모르겠어서 그냥
램프의 상태를 한줄씩 파악해서 스위치 작동 가능 횟수(K)로 스위치를 다 켤 수 있는지, 없는지 파악한 후에
가장 많은 패턴을 가지고 있는 것의 갯수를 출력하도록 했습니다.
이녀석으로 예를 들면
K는 6 ( 짝수 ) 라면 , 101, 000 같이 0이 홀 수인 것들은 킬 수 없습니다 111로..
이 점을 이용해서 모두 1로 킬 수 있는 것들을 따로 ArrayList < String > list 에 저장해두고~
그렇게되면 list 에 001 001 111 001 111 111 010 001 이런식으로 저장이 됩니다~
여기서 문제에 스위치를 누를 때마다 그 열에 있는 램프의 상태가 바뀐다. 라고 되어있는데
그럼 위에서 예를 들어,
001과 111이 스위치 모두 작동한 후에 둘다 111로 켜져있을 수는 없겠죠?!
그래서 저는
Collections.frequency(list, list.get(i)) 빈도수 체크 메서드를 이용해 가장 많은 패턴의 갯수가 결과값으로 나오도록 했습니다!
리뷰 요청 사항
느낀점