1

Hamming Distance

Unsolved
NLP

Difficulty: 1 | Problem written by bilaldadanlar

Educational Resource: https://en.wikipedia.org/wiki/Hamming_distance


Problem reported in interviews at

Amazon
Apple
Facebook
Google

Hamming distance compares 2 strings of equal length. The distance is the sum of number of positions at which the corresponding characters are different.

For example: "TK-215" and "HK-015" has a hamming distance of 2.

Write a function that, given two strings of the same length, returns their Hamming distance.

 

Sample Input:
<class 'str'>
s1: euclidean
<class 'str'>
s2: manhattan

Expected Output:
<class 'int'>
7

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Asperiores pariatur qui saepe molestias, voluptates voluptatum nesciunt quo earum, voluptatibus amet hic a commodi fuga quisquam blanditiis iste quae incidunt, facere vitae omnis tenetur perspiciatis corrupti molestias architecto corporis, neque dolorem aliquid quis reprehenderit atque qui inventore magnam?

Tempore quae rerum libero ex molestias, voluptates voluptatibus laborum officia hic? Quis facere fugit totam quibusdam explicabo fuga doloribus saepe soluta, magni minima hic cum blanditiis, voluptatibus corporis officia doloribus, dicta pariatur quam, harum quam nulla quia accusamus doloremque blanditiis ut est asperiores.

Libero minus est quasi et ab veniam? Explicabo a quidem ipsam tempore?

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)