Sort by

recency

|

189 Discussions

|

  • + 1 comment
    awk '  
    BEGIN { res = 0 }  
    
    NR == 2 {  
        for (i = 1; i <= NF; i++) {  
        el = $i  
        if (el in arr) {  
              res -= el  
          } else {  
              arr[el] = el  
              res += el  
          }  				
      }  		
      print res  
    }'
    
  • + 0 comments

    read n read -a array

    tmp=0 for value in "((tmp^value)) done echo $tmp

  • + 0 comments
    read N
    
    # Read the space-separated integers into an array and find the unique integers with their counts
    
    echo "$(< /dev/stdin)" | tr ' ' '\n' | sort | uniq -u
    
  • + 1 comment
    read n
    read -a arr
    
    temp=${arr[0]}
    for n in ${arr[@]:1}; do temp=$(( temp ^ n )); done
    
    echo $temp
    
  • + 0 comments

    Simple solution:

    #!/bin/bash
    
    read N
    read -a arr
    
    
    declare -A countElements
    
    for item in "${arr[@]}"; do
      ((countElements["$item"]++))
    done
    
    
    for key in "${!countElements[@]}"; do
      if ((countElements["$key"] == 1)); then
        echo "$key"
      fi
    done