One line solution with awk


  • 0
    A
    awk '{for(i=1;i<=NF;i++){if(NR==1){a[i] = $i}else{a[i] = a[i]" "$i;}}}END{for(i in a){print a[i];}}' file.txt
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.