We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d7e9d0 commit 0bd81e1Copy full SHA for 0bd81e1
1 file changed
BasicLevel_Java/1039 到底买不买 (20 分).java
@@ -0,0 +1,27 @@
1
+import java.io.BufferedReader;
2
+import java.io.IOException;
3
+import java.io.InputStreamReader;
4
+
5
+public class Main {
6
+ public static void main(String[] args) throws IOException {
7
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8
+ char[] c1 = br.readLine().toCharArray();
9
+ char[] c2 = br.readLine().toCharArray();
10
+ int[] flag = new int[256];
11
+ for (int i = 0; i < c1.length; i++) {
12
+ flag[c1[i]]++;
13
+ }
14
+ int count = c2.length;
15
+ for (int i = 0; i < c2.length; i++) {
16
+ if (flag[c2[i]] != 0){
17
+ flag[c2[i]]--;
18
+ count--;
19
20
21
+ if (count == 0) {
22
+ System.out.print("Yes " + (c1.length - c2.length));
23
+ }else {
24
+ System.out.print("No " + count);
25
26
27
+}
0 commit comments