Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 176f4a5

Browse files
solve: 특정 문자열로 끝나는 가장 긴 부분 문자열 찾기
1 parent da28f73 commit 176f4a5

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

‎Level0/PRO181872.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Solution 1
2+
function solution(myString, pat) {
3+
for (let i = myString.length; i >= 0; i--) {
4+
const partOfString = myString.substring(0, i);
5+
6+
if (partOfString.endsWith(pat)) {
7+
return partOfString;
8+
}
9+
}
10+
}
11+
12+
// Solution 2
13+
function solution2(myString, pat) {
14+
return myString.slice(0, myString.lastIndexOf(pat) + pat.length);
15+
}

‎README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@
317317

318318
### 2024년 01월
319319

320-
| 날짜 | 난이도 | 문제 | JS 풀이 |
321-
| :-------: | :-------: | :----------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------: |
322-
| 24.01.01. | `Level 0` | [특이한 정렬](https://school.programmers.co.kr/learn/courses/30/lessons/120880) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO120880.js) |
323-
| 24.01.02. | `Level 0` | [무작위로 K개의 수 뽑기](https://school.programmers.co.kr/learn/courses/30/lessons/181858) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO181858.js) |
320+
| 날짜 | 난이도 | 문제 | JS 풀이 |
321+
| :-------: | :-------: | :---------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------: |
322+
| 24.01.01. | `Level 0` | [특이한 정렬](https://school.programmers.co.kr/learn/courses/30/lessons/120880) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO120880.js) |
323+
| 24.01.02. | `Level 0` | [무작위로 K개의 수 뽑기](https://school.programmers.co.kr/learn/courses/30/lessons/181858) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO181858.js) |
324+
| 24.01.02. | `Level 0` | [특정 문자열로 끝나는 가장 긴 부분 문자열 찾기](https://school.programmers.co.kr/learn/courses/30/lessons/181872) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO181872.js) |

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /