fb pixel

Algorithms and Data Structures

  • Profound Academy

    • Status
      • 1
        Implementation
      • 2
        Bitwise operations
      • 3
        Prefix Sums
      • 4
        Sliding window / Two pointers
      • 5
        Modular Arithmetic
      • 6
        Number Theory
      • 7
        Binary Search
      • 8
        Basic Sorting
      • 9
        Greedy Algorithms

  • Minimum Hamming Distance

    Given n bit-strings, you are asked to find the pair of bit-strings that has the minimum hamming distance.

    Input

    The first line of the input contains a single integer n (1 ≤ n ≤ 1000).
    The next n lines contain bit-strings of the same length each on a separate line (1 ≤ || ≤ ).

    Output

    The program should print the minimum hamming distance of those pairs.

    Examples

    Input
    Output
    4 1111 1010 0000 1011
    1

    Explanation

    The hamming distance between 1011 and 1010 is 1.
     
    To check your solution you need to sign in
    Sign in to continue