Skip to content

Commit

Permalink
Use Int16List for inner int list
Browse files Browse the repository at this point in the history
  • Loading branch information
vincevargadev committed Dec 19, 2024
1 parent 6c9aeb6 commit fc18e35
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion levenshtein/dart/code.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import 'dart:math';
import 'dart:typed_data';

int levenshteinDistance(String word1, String word2) {
final m = word1.length;
final n = word2.length;
// Create a matrix to store distances
var matrix = List.generate(m + 1, (i) => List.generate(n + 1, (j) => 0));
var matrix = List.generate(
m + 1,
(i) => Int16List(n + 1),
);

// Initialize first row and column
for (int i = 1; i <= m; i++) {
Expand Down

0 comments on commit fc18e35

Please sign in to comment.