Sort by

recency

|

198 Discussions

|

  • + 0 comments

    using the concept of XOR

    #!/bin/bash
    
    read a
    read -a arr
    count="${#arr[@]}"
    ans="${arr[0]}"
    
    
    for((i=1;i<count;i++));do
        (( ans= ans ^ "${arr[i]}" ))
    done
    
    echo "$ans"
    
  • + 0 comments

    !/bin/bash

    read -r n read -r line

    echo "$line" | tr " " "\n" | sort | uniq -u

  • + 0 comments

    read N read m echo $m | tr ' ' '\n' > file.txt sort file.txt | uniq -u

  • + 1 comment

    tr " " "\n" | tail +2 | sort | uniq -u tr is used so each array element in new line for further processing tail is used to skip 1st line which contain total no. of array elements sort for uniq cmd to work as desired uniq -u print only the uniq element

  • + 0 comments
    read N
    readarray numbers
    printf "%s\n" ${numbers[@]} | sort -rn | uniq -u