Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- class Solution {
- public static void main(String args[])
- {
- Scanner in = new Scanner(System.in);
- int N = in.nextInt();
- Map<String, String> hashMap = new HashMap<>();
- String emojis[] = new String[N];
- String regex = "(";
- for (int i = 0; i < N; i++)
- {
- String EMOJI = in.next();
- String CODE = in.next();
- hashMap.put(EMOJI, CODE);
- emojis[i] = EMOJI;
- }
- in.nextLine();
- String S = in.nextLine();
- for(String x : emojis)
- S = S.replace(x,hashMap.get(x));
- // pour que ça marche pour ":))))" -> ":)"
- // dans la boucle for : je crée un regex += l'émoji et puis regex += "+" -> exemple regex = ":)+" ez
- // puis S.replaceAll(regex, replacement); ez
- System.out.println(S);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement