Skip to content

[hyejj19] WEEK 06 Solutions#2518

Open
hyejj19 wants to merge 3 commits intoDaleStudy:mainfrom
hyejj19:main
Open

[hyejj19] WEEK 06 Solutions#2518
hyejj19 wants to merge 3 commits intoDaleStudy:mainfrom
hyejj19:main

Conversation

@hyejj19
Copy link
Copy Markdown
Contributor

@hyejj19 hyejj19 commented Apr 8, 2026

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@dalestudy
Copy link
Copy Markdown
Contributor

dalestudy bot commented Apr 8, 2026

📊 hyejj19 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
best-time-to-buy-and-sell-stock Easy ✅ 의도한 유형
container-with-most-water Medium ✅ 의도한 유형
valid-parentheses Easy ✅ 의도한 유형

누적 학습 요약

  • 풀이한 문제: 7 / 75개
  • 이번 주 유형 일치율: 100% (3문제 중 3문제 일치)

문제 풀이 현황

카테고리 진행도 완료
Bucket Sort ■■■■■■■ 1 / 1 (Medium 1)
Counting ■■■■■■■ 1 / 1 (Medium 1)
Quickselect ■■■■■■■ 1 / 1 (Medium 1)
Memoization ■■■■□□□ 1 / 2 (Easy 1)
Prefix Sum ■■■■□□□ 1 / 2 (Medium 1)
Hash Table ■■□□□□□ 5 / 16 (Easy 3, Medium 2)
Sorting ■■□□□□□ 3 / 11 (Easy 2, Medium 1)
Heap (Priority Queue) ■■□□□□□ 1 / 4 (Medium 1)
Union-Find ■■□□□□□ 1 / 4 (Medium 1)
Math ■□□□□□□ 1 / 5 (Easy 1)
Divide and Conquer ■□□□□□□ 1 / 6 (Medium 1)
Array ■□□□□□□ 5 / 36 (Easy 2, Medium 3)
Dynamic Programming □□□□□□□ 1 / 18 (Easy 1)
String □□□□□□□ 1 / 19 (Easy 1)
Backtracking □□□□□□□ 0 / 3 ← 아직 시작 안 함
Binary Search □□□□□□□ 0 / 4 ← 아직 시작 안 함
Binary Search Tree □□□□□□□ 0 / 3 ← 아직 시작 안 함
Binary Tree □□□□□□□ 0 / 11 ← 아직 시작 안 함
Bit Manipulation □□□□□□□ 0 / 5 ← 아직 시작 안 함
Breadth-First Search □□□□□□□ 0 / 13 ← 아직 시작 안 함
Combinatorics □□□□□□□ 0 / 1 ← 아직 시작 안 함
Data Stream □□□□□□□ 0 / 1 ← 아직 시작 안 함
Depth-First Search □□□□□□□ 0 / 18 ← 아직 시작 안 함
Design □□□□□□□ 0 / 5 ← 아직 시작 안 함
Graph Theory □□□□□□□ 0 / 5 ← 아직 시작 안 함
Greedy □□□□□□□ 0 / 4 ← 아직 시작 안 함
Hash Function □□□□□□□ 0 / 1 ← 아직 시작 안 함
Linked List □□□□□□□ 0 / 6 ← 아직 시작 안 함
Matrix □□□□□□□ 0 / 7 ← 아직 시작 안 함
Merge Sort □□□□□□□ 0 / 1 ← 아직 시작 안 함
Recursion □□□□□□□ 0 / 3 ← 아직 시작 안 함
Simulation □□□□□□□ 0 / 1 ← 아직 시작 안 함
Sliding Window □□□□□□□ 0 / 3 ← 아직 시작 안 함
Stack □□□□□□□ 0 / 2 ← 아직 시작 안 함
String Matching □□□□□□□ 0 / 1 ← 아직 시작 안 함
Topological Sort □□□□□□□ 0 / 2 ← 아직 시작 안 함
Tree □□□□□□□ 0 / 11 ← 아직 시작 안 함
Trie □□□□□□□ 0 / 4 ← 아직 시작 안 함
Two Pointers □□□□□□□ 0 / 10 ← 아직 시작 안 함

🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다.

@hyejj19 hyejj19 marked this pull request as ready for review April 8, 2026 06:30
Copilot AI review requested due to automatic review settings April 8, 2026 06:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds TypeScript solution submissions for Week 06 LeetCode study problems.

Changes:

  • Added a stack-based parentheses validation solution (valid-parentheses).
  • Added a two-pointer maximum container area solution (container-with-most-water).
  • Added a single-pass max profit solution (best-time-to-buy-and-sell-stock).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
valid-parentheses/hyejj19.ts Adds a stack-based implementation for Valid Parentheses (currently contains duplicate isValid implementations).
container-with-most-water/hyejj19.ts Adds a two-pointer solution for Container With Most Water.
best-time-to-buy-and-sell-stock/hyejj19.ts Adds a max profit solution (currently contains duplicate maxProfit implementations and isn’t reflected in the PR checklist).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +31
function isValid(s: string): boolean {
const stack = [];
const open = '([{';
for (const v of s) {
if (open.includes(v)) {
stack.push(v);
} else {
if (
(v === ')' && stack.at(-1) === '(') ||
(v === '}' && stack.at(-1) === '{') ||
(v === ']' && stack.at(-1) === '[')
) {
// 일치하는 닫는 괄호라면 pop
stack.pop();
} else {
// 일치하지 않는 닫는 괄호라면 false
return false;
}
}
}

return stack.length === 0 ? true : false;
}

function isValid(s: string): boolean {
const pairs = new Map([
[')', '('],
['}', '{'],
[']', '['],
]);
const stack = [];
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two isValid function implementations in the same file. In TypeScript this is a duplicate implementation and will cause a compile error / make it unclear which solution is intended. Keep only one implementation (or rename one to something like isValidV1 if you want to keep both for comparison).

Copilot uses AI. Check for mistakes.
}
}

return stack.length === 0 ? true : false;
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return stack.length === 0 ? true : false; is redundant—stack.length === 0 already evaluates to a boolean. Returning the condition directly is simpler and consistent with the second implementation below.

Suggested change
return stack.length === 0 ? true : false;
return stack.length === 0;

Copilot uses AI. Check for mistakes.
function maxArea(height: number[]): number {
let left = 0;
let right = height.length - 1;
let max = -1;
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max is initialized to -1, which means this function returns -1 when height.length < 2 (even though the max area cannot be negative). Initializing to 0 (and optionally early-returning 0 for short inputs) avoids an invalid negative result and matches the non-negative domain of the problem.

Suggested change
let max = -1;
let max = 0;

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +26

function maxProfit(prices: number[]): number {
let minPrice = Infinity;
let maxProfit = 0;

for (let p of prices) {
minPrice = Math.min(minPrice, p);
maxProfit = Math.max(maxProfit, p - minPrice);
}
return maxProfit;
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file defines maxProfit twice. As with isValid, this is a duplicate function implementation in TypeScript and will fail to compile / makes the intended final solution ambiguous. Please keep a single maxProfit implementation (or rename one if you want to preserve both).

Suggested change
function maxProfit(prices: number[]): number {
let minPrice = Infinity;
let maxProfit = 0;
for (let p of prices) {
minPrice = Math.min(minPrice, p);
maxProfit = Math.max(maxProfit, p - minPrice);
}
return maxProfit;
}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +5
function maxProfit(prices: number[]): number {
let minPrice = Number.MAX_SAFE_INTEGER;
let maxProfit = 0;

for (let p of prices) {
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description checklist indicates solutions submitted for #222 and #242, but this PR also adds a solution for "best-time-to-buy-and-sell-stock". Please either update the PR description checklist to include this problem, or remove this file from the PR to keep the description in sync with the actual changes.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Solving

Development

Successfully merging this pull request may close these issues.

2 participants