Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const readline = require('readline');
- const io_interface = readline.createInterface({
- input: process.stdin
- });
- let lineNumber = 0,
- s,
- t;
- io_interface.on('line', function(line) {
- if (lineNumber === 0) {
- s = line;
- } else if (lineNumber < 2) {
- t = line;
- }
- lineNumber++;
- })
- io_interface.on('close', function() {
- if (isStrangeEqual(s, t)) {
- console.log('YES');
- } else {
- console.log('NO');
- }
- })
- function isStrangeEqual(s, t) {
- if (s.length !== t.length) {
- return false;
- }
- let map = {};
- for (const index in s) {
- if (!map.hasOwnProperty(s[index].charCodeAt(0))) {
- map[s[index].charCodeAt(0)] = t[index].charCodeAt(0);
- } else {
- if (map[s[index].charCodeAt(0)] !== t[index].charCodeAt(0)) {
- return false;
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement