18 lines
617 B
C++
18 lines
617 B
C++
#include <algorithm>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
/**
|
|
* @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);
|