fix(security): 2 improvements across 2 files#2612
Conversation
- Security: Syntax Error: Invalid return statement in Go file - Security: Undefined variable 'seen' in JavaScript file Signed-off-by: tomaioo <[email protected]>
- Security: Syntax Error: Invalid return statement in Go file - Security: Undefined variable 'seen' in JavaScript file Signed-off-by: tomaioo <[email protected]>
|
There was a problem hiding this comment.
π·οΈ μκ³ λ¦¬μ¦ ν¨ν΄ λΆμ
- ν¨ν΄: Two Pointers
- μ€λͺ : μ΄ μ½λλ μ λ ¬λ λ°°μ΄μμ λ ν¬μΈν°λ₯Ό νμ©νμ¬ 3κ°μ μμ ν©μ΄ 0μ΄ λλ μ‘°ν©μ μ°Ύλ λ°©μμΌλ‘, Two Pointers ν¨ν΄μ μν©λλ€. ν¨μ¨μ μΈ νμμ μν΄ μ€λ³΅ μ κ±°μ μ λ ¬μ νμ©ν©λλ€.
π μκ°/κ³΅κ° λ³΅μ‘λ λΆμ
| 볡μ‘λ | |
|---|---|
| Time | O(n^2) |
| Space | O(n) |
νΌλλ°±: μ΄ κ΅¬νμ μ΄μ€ λ°λ³΅λ¬Έκ³Ό ν΄μμ μ μ¬μ©νμ¬ μ€λ³΅μ λ°©μ§νλ©°, μκ° λ³΅μ‘λλ λ λ°λ³΅λ¬Έμ΄ κ°κ° O(n)μ΄κ³ ν΄μμ μ°μ°μ΄ νκ· O(1)μ΄κΈ° λλ¬Έμ O(n^2)μ λλ€. 곡κ°μ ν΄μμ κ³Ό κ²°κ³Ό μ μ₯μ O(n)μ λλ€.
κ°μ μ μ: νμ¬ κ΅¬νμ΄ μ μ ν΄ λ³΄μ λλ€.
π‘ νμ΄μ μκ°/κ³΅κ° λ³΅μ‘λλ₯Ό μ£ΌμμΌλ‘ λ¨κ²¨λ³΄μΈμ!
There was a problem hiding this comment.
π·οΈ μκ³ λ¦¬μ¦ ν¨ν΄ λΆμ
- ν¨ν΄: Two Pointers
- μ€λͺ : μ΄ μ½λλ μ λ ¬λ λ°°μ΄μμ λ ν¬μΈν°λ₯Ό νμ©νμ¬ 3κ°μ μμ ν©μ΄ 0μ΄ λλ μ‘°ν©μ μ°Ύλ λ°©μμΌλ‘, ν¨μ¨μ μΈ νμμ μν΄ Two Pointers ν¨ν΄μ μ¬μ©ν©λλ€.
π μκ°/κ³΅κ° λ³΅μ‘λ λΆμ
| 볡μ‘λ | |
|---|---|
| Time | O(n^2) |
| Space | O(n) |
νΌλλ°±: μ΄ κ΅¬νμ μ΄μ€ λ°λ³΅λ¬Έκ³Ό ν΄μμ μ μ¬μ©νμ¬ μ€λ³΅μ λ°©μ§νλ©°, μκ° λ³΅μ‘λλ λ λ°λ³΅λ¬Έμ΄ κ°κ° O(n)μ΄κ³ ν΄μμ μ°μ°μ΄ νκ· O(1)μ΄κΈ° λλ¬Έμ O(n^2)μ λλ€. 곡κ°μ ν΄μμ κ³Ό κ²°κ³Ό μ μ₯μ O(n)μ λλ€.
κ°μ μ μ: νμ¬ κ΅¬νμ΄ μ μ ν΄ λ³΄μ λλ€.
π‘ νμ΄μ μκ°/κ³΅κ° λ³΅μ‘λλ₯Ό μ£ΌμμΌλ‘ λ¨κ²¨λ³΄μΈμ!
|
@tomaioo The changes aren't security-related despite the PR title. This is a study repo where each member submits only their own solutions under their own filename. We don't accept external fixes to other members' submissions. |
Summary
fix(security): 2 improvements across 2 files
Problem
Severity:
High| File:3sum/tedkimdev.go:L42In tedkimdev.go, the function contains
return result.keys()at the end, which is invalid Go syntax. Maps in Go do not have a.keys()method. This would cause a compilation error. The correct approach would be to iterate over the map and build the slice, or use the already-builtfilteredResultvariable.Solution
Replace
return result.keys()withreturn filteredResultsincefilteredResultis already correctly populated in the lines above.Changes
3sum/tedkimdev.go(modified)3sum/lhc0506.js(modified)