fork download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. var a = [[0, 47], [50, 51], [53, 53], [55, 55], [58, 97], [101, 101], [103, 1114111]];
  5. var b = [[48, 57], [97, 102]];
  6.  
  7. var output = [];
  8.  
  9. for (var i = 0; i < a.length; ++i) {
  10. for (var j = 0; j < b.length; ++j) {
  11. var intersection = [
  12. Math.max(a[i][0], b[j][0]),
  13. Math.min(a[i][1], b[j][1]),
  14. ];
  15.  
  16. if (intersection[0] <= intersection[1]) {
  17. output.push(intersection)
  18. }
  19. }
  20. }
  21.  
  22. console.log(output);
Success #stdin #stdout 0.05s 12032KB
stdin
Standard input is empty
stdout
[ [ 50, 51 ], [ 53, 53 ], [ 55, 55 ], [ 97, 97 ], [ 101, 101 ] ]