-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[선재] WEEK4 Solution #419
[선재] WEEK4 Solution #419
Conversation
maximum-subarray/sunjae95.js
Outdated
@@ -0,0 +1,81 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 문제는 여러방법으로 시도해봤지만 시간초과를 해결하지 못하여 시도방법만 제출합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 @Sunjae95 님
자료구조까지 직접 만들어서 하시다니 멋지네요!
이번 한 주도 고생 많으셨습니다!
|
||
class CustomQueue { | ||
constructor() { | ||
this.items = new Map(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index
를 사용해 관리하신다면 Map
보다는 Array
가 더 효율적이지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
동의합니다.
우선순위큐 자체가 배열의 가장 마지막 인자를 제거하는 로직이라서 Array를 사용하는게 map method를 사용하지 하는것보다 효율적이고 명시적으로 보이네요!
this.heapifyUp(); | ||
} | ||
|
||
remove() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리턴값이 있다는 점에서 remove
보다는 pop
이 어떨까 조심스레 의견 드립니다..!!
*/ | ||
var longestConsecutive = function (nums) { | ||
const queue = new CustomQueue(); | ||
let [count, before, answer] = [0, null, 0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 구조분해할당을 처음 할당할 때에도 쓰면 좋네요
} | ||
} | ||
|
||
class CustomQueue { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
브레인 스토밍에서 의견주신것처럼 CustomQueue
보다는 PriorityQueue
등으로 활용하시는 것이 좀 더 명확할것같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 요거는 리트코드에서 미리선언되어있어서 참조에러가 나더라구요
아마 있는거 같지만 해당 문서를 찾지 못해서 이름만 바꿔서 구현했어요..😅
let answer = false; | ||
const ROW_LENGTH = board.length; | ||
const COLUMN_LENGTH = board[0].length; | ||
// O(n^2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은, 보드가 정사각형이라는 언급이 없으므로 O(m x n)
등으로 표현해주시는게 좋지 않을까 싶어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그렇군요! 보통 m x n으로 표현하는지 몰랐는데 알게됐네요 감사합니다!
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.