fork(5) download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. // your code goes here
  5. var readline = require('readline');
  6.  
  7. var rl = readline.createInterface({
  8. input: process.stdin,
  9. output: process.stdout,
  10. terminal: false
  11. });
  12.  
  13. rl.on('line', function (line) {
  14. var arr = line.split('');
  15. for (var i = 0; i < arr.length; i++) {
  16. var count = 0;
  17. for (var j = 0; j < arr.length; j++) {
  18. if (arr[i] === arr[j]) {
  19. count++
  20. }
  21. }
  22. }
  23. if (count == 2) {
  24. let res = arr.join('')
  25. console.log(res)
  26. }
  27. });
  28.  
Success #stdin #stdout 0.07s 30272KB
stdin
asdf
fdas
asds
d fm
dfaa
aaaa
stdout
asds
dfaa