Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions 09월/1주차/[LCD] Best Time to Buy and Sell Stock/Mun.java

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

불필요한 요소를 줄이니까 훨씬 간단하고 보기 편한 풀이 방식인것 같습니다! 👍🏻

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Mun {
public int maxProfit(int[] prices) {
int min = Integer.MAX_VALUE;
int max = 0;

for (int price : prices) {
min = Math.min(min, price);
max = Math.max(max, price - min);
}

return max;
}
}
21 changes: 21 additions & 0 deletions 09월/1주차/[LCD] Pascal's Triangle II/Mun.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Mun {
public List<Integer> getRow(int rowIndex) {
List<List<Integer>> list = new ArrayList<>();
list.add(List.of(1));
list.add(List.of(1, 1));
if(rowIndex < 2) {
return list.get(rowIndex);
}
for(int i=2;i<=rowIndex;i++) {
List<Integer> before = list.get(i-1);
List<Integer> now = new ArrayList<>();
Comment on lines +10 to +11

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

리스트 두개로 나눠서 이전열과 다음열을 구분해 볼 수 있어 보기 편했습니다!

now.add(1);
for(int j=1;j<i;j++) {
now.add(before.get(j-1) + before.get(j));
}
now.add(1);
list.add(now);
}
return list.get(rowIndex);
}
}