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
24 changes: 24 additions & 0 deletions 1603. Design Parking System/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 1603. Design Parking System

[Design Parking System](https://leetcode.com/problems/design-parking-system/)

## 김시현 - 2023.05.29

- 클래스 내 메소드 구현
- carType이 정수 1,2,3으로 입력받아서 배열의 index로 이용하면 편할 것 같아서 park 배열을 선언하고 값을 넣어줬다.
- 배열의 값이 0보다 크기만 하면 공간이 있다는 뜻이므로 true를 return한다.
- park배열을 ParkingSystem에서 한 번에 초기화해서 코드를 더 깔끔하게 수정하였다.

```java
class ParkingSystem {
int[] park;

public ParkingSystem(int big, int medium, int small) {
park = new int[] {big, medium, small};
}

public boolean addCar(int carType) {
return park[carType - 1]-- > 0;
}
}
```
20 changes: 20 additions & 0 deletions 1732. Find the Highest Altitude/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 1732. Find the Highest Altitude

[Find Smallest Letter Greater Than Target](https://leetcode.com/problems/find-smallest-letter-greater-than-target/)

## 김시현 - 2023.06.19

- for문 돌면서 sum에 더하여 저장, sum이 max보다 큰 경우 바꿔줌

```java
class Solution {
public int largestAltitude(int[] gain) {
int sum = 0, max = 0;
for(int i = 0; i < gain.length; i++) {
sum += gain[i];
max = Math.max(sum, max);
}
return max;
}
}
```
22 changes: 22 additions & 0 deletions 2490. Circular Sentence/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 2490. Circular Sentence

[Circular Sentence](https://leetcode.com/problems/circular-sentence/)

## 김시현 - 2023.06.29

- sentence를 공백으로 나누어 String 배열에 넣어주고 for문 돌면서
마지막 문자와 다음 String 첫 문자를 비교해준다.

```java
class Solution {
public boolean isCircularSentence(String sentence) {
String[] str = sentence.split(" ");
for(int i = 0; i < str.length; i++) {
if(str[i].charAt(str[i].length() - 1)
!= str[(i + 1) % str.length].charAt(0))
return false;
}
return true;
}
}
```
17 changes: 17 additions & 0 deletions 744. Find Smallest Letter Greater Than Target/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 744. Find Smallest Letter Greater Than Target

[Find Smallest Letter Greater Than Target](https://leetcode.com/problems/find-smallest-letter-greater-than-target/)

## 김시현 - 2023.06.09

- letters배열에 for문 돌면서 저장된 아스키코드값을 비교해 target보다 크면 return
- 배열에 더 큰 값이 없다면 letters[0] return

```java
class Solution {
public char nextGreatestLetter(char[] letters, char target) {
for(var c: letters) if(c > target) return c;
return letters[0];
}
}
```