Problem:
Given a rectangular matrix containing only digits, calculate the number of different 2 × 2 squares in it.
Example
For
the output should be
differentSquares(matrix) = 6.
Here are all 6 different 2 × 2 squares:
- 1 2
2 2 - 2 1
2 2 - 2 2
2 2 - 2 2
1 2 - 2 2
2 3 - 2 3
2 1
-Summary-
1. set variable을 만들어서 matrix 의 4*4 의 각 숫자를 string으로 만들어 저장해준다.
2. 만약 똑같은 value가 이미 있다면 저장되지 않고, 똑같은 value가 없다면 새로 저장될 것이다.
3. return length of the set.
모든 문제에 대한 저작권은 CodeSignal 회사에 있습니다. [Copyright © 2020 BrainFights Inc. All rights reserved]
'CodeSignal > Arcade' 카테고리의 다른 글
CodeSignal [57/60] fileNaming (0) | 2020.05.28 |
---|---|
CodeSignal [56/60] digitsProduct (0) | 2020.05.28 |
CodeSignal [54/60] sumUpNumbers (0) | 2020.05.28 |
CodeSignal [53/60] validTime (0) | 2020.05.28 |
CodeSignal [52/60] longestWord (0) | 2020.05.28 |
댓글