알고리즘 문제 풀이: 자바/Programmers

[프로그래머스] 특정 문자열로 끝나는 가장 긴 부분 문자열 찾기

hueco 2024. 1. 5.

 

📌 문제 링크: https://school.programmers.co.kr/learn/courses/30/lessons/181872

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

내 풀이(Success) :

 

🧐 Review:

 String 클래스의 lastIndexOf() 메서드는 부분 문자열이 문자열에서 마지막으로 등장을 시작하는 인덱스를 반환한다.

예를 들어,

위 코드에서 출력값은 "dE"가 시작되는 인덱스인 3이 출력된다.

 

 

🏷️ Reference:

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html#lastIndexOf(java.lang.String)

 

String (Java SE 11 & JDK 11 )

Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence represented by the argum

docs.oracle.com

 

 

 

댓글