View
λ°μν
λ¬Έμ λ₯Ό λ무 μ½κ² μκ°νλλ μκ°μ΄κ³Ό
λ²μλ₯Ό 보λ 무μνκ² νλ©΄ μλκ² μ -> μμ΄λ μλ λ―
μ’ λ μκ°ν΄λ³΄μ
package λ°±μ€;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main_1593 {
public static void main(String[] args) throws IOException {
// W: cAda
// g: 4
// S:AbrAcadAbRa
// gS: 11
// Acad
// cadA
// λ€λ₯Έ λ°©λ²μ μκ°ν΄μΌν¨
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int wSize = Integer.parseInt(st.nextToken());
int sSize = Integer.parseInt(st.nextToken());
int cnt = 0;
String w = br.readLine();
char[] wC = w.toCharArray();
String s = br.readLine();
char[] sC = s.toCharArray();
char[] tmp = new char[w.length()];
// λ¬Έμμ΄ μ λ ¬
Arrays.sort(wC);
int i = 0;
int j = 0;
while (j < sC.length) {
int k = 0;
for (j = i; j < i + wC.length; j++) {
tmp[k] = sC[j];
k++;
}
Arrays.sort(tmp);
if (Arrays.equals(tmp, wC)) {
cnt += 1;
}
i += 1;
}
System.out.println(cnt);
}
}
π‘ λ λ°°μ΄μ λ΄μ©μ΄ κ°μμ§ λΉκ΅
if (Arrays.equals(tmp1, tmp2))
λ°μν
'μκ³ λ¦¬μ¦ > μ½λ©ν μ€νΈ' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[λ°±μ€] 2630: μμ’ μ΄ λ§λ€κΈ°(λΆν μ 볡) (0) | 2022.10.03 |
---|---|
[λ°±μ€] 10814: λμ΄μ μ λ ¬(Java) (0) | 2022.10.03 |
[SWEA]1249: 보κΈλ‘ D4(Java) (0) | 2022.10.02 |
[νλ‘κ·Έλλ¨Έμ€] μμ£Όνμ§ λͺ»ν μ μ(Java) (0) | 2022.10.01 |
[λ°±μ€] 2879: μνμμ (Java) (0) | 2022.10.01 |
reply