Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Method
- string
- java
- greedy
- 파이썬
- Matrix
- geometry
- Binary Search
- two pointers
- hash table
- Data Structure
- implement
- Math
- Class
- Counting
- bit manipulation
- 자바
- sorting
- database
- Stack
- simulation
- array
- Tree
- 코테
- dynamic programming
- Number Theory
- Binary Tree
- 코딩테스트
- SQL
- 구현
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 1528. Shuffle String 본문
1. Input
1) 문자열 s
2) [0, n-1]의 정수가 담긴 배열 indices
- n == s.length
2. Output
1) s의 문자들을 indices에 나온것처럼 섞었을때의 결과 문자열
3. Constraint
1) s.length == indices.length == n
2) 1 <= n <= 100
3) s는 영어 소문자로만 이루어져 있다.
4) 0 <= indices[i] < n
5) indices에는 중복 숫자가 없다,
4. Example
Input: s = "codeleet", indices = [4,5,6,7,0,2,1,3] -> Output: "leetcode"
설명:
- 0번째인 c를 4번째로
- 1번째인 o를 5번째로
- 2번째인 d를 6번째로
...
- 다 섞고 나면 “leetcode”가 된다.
5. Code
1) 첫 코드(2022/06/04)
int n = s.length();
String result = "";
for(int i=0 ; i<n ; i++){
for(int j=0 ; j<n ; j++){
if(indices[j] == i){
result += s.charAt(j) + "";
break;
}
} // for j
} // for i
return result;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 1544. Make The String Great (0) | 2022.12.27 |
---|---|
[LeetCode/Easy] 1534. Count Good Triplets (0) | 2022.12.27 |
[LeetCode/Easy] 1523. Count Odd Numbers in an Interval Range (0) | 2022.12.27 |
[LeetCode/Easy] 1512. Number of Good Pairs (0) | 2022.12.27 |
[LeetCode/Easy] 1507. Reformat Date (0) | 2022.12.27 |