labs-edaf30/lab2/edit_distance.h
2024-11-21 08:49:45 +01:00

17 lines
564 B
C++

#include <string>
/**
* @brief Computes the edit distance (Levenshtein distance) between two strings.
*
* The edit distance is defined as the minimum number of single-character edits
* (insertions, deletions, or substitutions) required to transform one string
* into the other.
*
* This implementation uses dynamic programming to compute the distance
* efficiently.
*
* @param s1 The first string.
* @param s2 The second string.
* @return The edit distance between the two strings.
*/
int edit_distance(const std::string &s1, const std::string &s2);