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.
π λ¬Έμ λ§ν¬
Find Valid Matrix Given Row and Column Sums
βοΈ μμλ μκ°
8μκ°
β¨ μλ μ½λ
λ¬Έμ μ€λͺ
μ λ ₯κ°μΌλ‘ κ° νμ μμλ€μ λν κ°κ³Ό κ° μ΄μ μμλ€μ λν κ°μ΄ μ£Όμ΄μ§λ€.
Input: rowSum = [3,8], colSum = [4,7]
rowSum[0] λ²μ§Έ νμ μμλ€μ λͺ¨λ λν κ°μ 3μ΄ λκ³
colSum[0] λ²μ§Έ μ΄μ μμλ€μ λͺ¨λ λν κ°μ 4κ° λλ€.
μ κ°μ΄ ꡬμ±μ΄ λμ΄μΌ νλ€.
첫 λ²μ§Έ μ κ·Ό λ°©μ
ν μΈλ±μ€
rIndex
μ μ΄ μΈλ±μ€cIndex
κ° 0λΆν° μμν΄μans
νλ ¬μ ν΄λΉνλ λΆλΆans[rindex][cindex]
κ° μμΉνλ λΆλΆμ κ° μ€ μ΅μ κ°μ λ£μΌλ©΄μ νλ©΄ λμ§ μμκΉμλ€.μ΅μκ°μ λ°°μΉν λ§νΌ
rowSum
κ³ΌcolSum
μμ λΉΌμ νκ³Ό μ΄μ μΈλ±μ€λ₯Ό μ μ°¨ μ¦κ°μν€λ λ°©μμΌλ‘ μ κ·ΌνμμΌλ λ°νμ μλ¬κ° λ°μνμλ€.μλ¬λ ν λ²νΌ μ€λ²νλ‘μ°λ‘ μ΅μκ°μ ꡬν λ μΈλ±μ€κ°
rowSum
κ³ΌcolSum
μ λ²μ΄λλ μν©μ΄ λ°μν κ²μ΄μλ€.μ¬κΈ°μ λ¬Έλλ μκ°μ μ°λ¦¬κ° λ§λλ νλ ¬μ λͺ¨λ μλ₯Ό μ¨μ νκ³Ό μ΄λ€μ ν©λ€μ μΌμΉμμΌμ€μΌνλκ² μλκ°? μκ³ μμΈμ¬νλ€μ μ°Ύλ€λ³΄λ μκ°μ΄ μ€λκ±Έλ¦¬κ² λμλ€.
νμ΄ λ°©μ
rowSum
κ³ΌcolSum
μ λ€ νμνλ λ°°μ΄μ κ°μ΄ λ¨μ κ²½μ° λ€ μ±μμ£Όλ λ°©μμΌλ‘ κ°κΈ°λ‘νμλ€.rIndex
,cIndex
μ κ°λ€μ ν΅ν΄ μ΅μκ°μ νμ νκ³ μ λ°μ΄νΈνλ€.rowSum
κ³ΌcolSum
μμ 0μ΄ λ°μνλ©΄ ν΄λΉνλ μΈλ±μ€μ κ°μ μ¦κ°μμΌμ€λ€.λλ²μ§Έ νμ΄
λ¬Έμ μμλ μꡬ μ¬νμ μΆ©μ‘±νλ 2D λ°°μ΄μ λ°ννλ€κ³ λμ΄μλ€.
μ¦,
rowSum
μ μμλ€μ λͺ¨λ ν©κ³ΌcolSum
μ μμλ€μ λͺ¨λ ν©μ΄ κ°μμΌ μꡬ μ¬νμ μΆ©μ‘±νλ λ°°μ΄μ΄ λ°νμ΄ λλ€.κ·ΈλΌ κ²°κ΅ μμ μκ³ λ¦¬μ¦μ μ§ννλ€λ³΄λ©΄ 맨 λ§μ§λ§μΌλ‘ λΉκ΅νλ κ°λ€μ μλ‘ κ°μ κ°μ΄ λλ©° μΆκ°μ μΈ μ°μ°μ΄ νμμμ΄μ§κ² λλ€.
π μλ‘κ² μκ²λ λ΄μ©