code optimisation

  1. nested for loops
      optimization;programming;
    resolve nested for loops by preventing repeated iterations