Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to calculate the edit distance (Levenshtein distance) between two strings.

Hard

Problem Statement

Write a function to calculate the edit distance (Levenshtein distance) between two strings.

Sample Input

"kitten" and "sitting"

Sample Output

Edit distance: 3

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
function editDistance(str1: string, str2: string): number { // Your logic here }
Log in or sign up to run or submit your code.Log inSign up
Input
"kitten" and "sitting"
Expected Output
Edit distance: 3