AC Solution: 8 lines only in pure Bash


  • 0
    Y
    while read -a line; do
        for ((i=0; i < "${#line[@]}"; i++)); do
            a[$i]="${a[$i]} ${line[$i]}"
        done
    done < file.txt
    for ((i=0; i < ${#a[@]}; i++)); do
        echo ${a[i]}
    done

Log in to reply
 

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