0% found this document useful (0 votes)
5 views18 pages

Edit Distance Calculation for Documents

Uploaded by

parthchunara799
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views18 pages

Edit Distance Calculation for Documents

Uploaded by

parthchunara799
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

68

68

68
06
00 Parul University

00

00
0
6

26

6
12

12

12
31
03

03

03
0
Name: Rudra Goti Scan to verify results
03

03

03

03
23

23

23

23
Email: 2303031260068@[Link]
Roll no: 2303031260068
Phone: 8200645188
Branch: Parul University
Department: CYBER1_Batch 1
Batch: 2027
Degree: [Link] - Cyber
8

68

8
06

06

06
00
0

60

60
26

26

PIET_DAA_Course

12

12
1

31
03

03

03
30
03

03

03
0

PIET_DAA_Session 9_COD
23

23

23

23
Attempt : 1
Total Mark : 70
Marks Obtained : 70

Section 1 : Coding

1. Problem Statement
8

68

68
06

06
00

00
60

60
6

6
Isabella is part of a team working on a collaborative report. Three team
12

12

12

12
03

03

03

members—Alice, Bob, and Carlos—have independently made edits to the 03


03

03

03

03
same initial draft of a document. These edits resulted in three different
23

23

23

23

versions of the document.


Now, Isabella's task is to calculate the edit distance between three
versions of a document to determine the at least editing required to bring
all versions to a common form. For each edit, cost is 1.

Input Format
The first line of input consists of a string, representing doc1.
8

8
06

06

06

06
60

60

60

60

The second line of input consists of a string, representing doc2.


12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
The third line of input consists of a string, representing doc3.
00

00

00
0
6

26

6
12

12

12
Output Format

31
03

03

03
0
03

03

03

03
The first line of output prints "The edit distance between doc1 and doc2: ".
23

23

23

23
The second line of output prints "The edit distance between doc2 and doc3: ".

The third line of output prints "The edit distance between doc1 and doc3: ".

The last line of output print "Minimum total edits needed: ".
8

68

8
06

06

06
00
0

60

60
26

26

Refer to the sample output for formatting specifications.

12

12
1

31
03

03

03
30

Sample Test Case


03

03

03
0
23

23

23

23
Input: program
programming
programing
Output: Edit distance between doc1 and doc2: 4
Edit distance between doc2 and doc3: 1
Edit distance between doc1 and doc3: 3
Minimum total edits needed: 4
Answer
8

68

68
06

06
00

00
#include <stdio.h>
60

60
6

6
#include <string.h>
12

12

12

12
03

03

03

03
#include <stdlib.h>
03

03

03

03
23

23

23

23

#define MAX_LEN 1000


int min(int a, int b, int c) {
int temp = (a < b) ? a : b;
return (temp < c) ? temp : c;
}

int editDistance(char* str1, char* str2) {


int len1 = strlen(str1);
int len2 = strlen(str2);
8

8
06

06

06

06

int dp[MAX_LEN][MAX_LEN];
60

60

60

60

for(int i = 0; i <= len1; i++)


12

12

12

12
03

03

03

03

dp[i][0] = i;
03

03

03

03
23

23

23

23
68

68

68
06
for(int j = 0; j <= len2; j++)
00

00

00
0
dp[0][j] = j;
6

26

6
12

12

12
31
for(int i = 1; i <= len1; i++) {
03

03

03
0
for(int j = 1; j <= len2; j++) {
03

03

03

03
23

23

23

23
if(str1[i-1] == str2[j-1])
dp[i][j] = dp[i-1][j-1];
else
dp[i][j] = 1 + min(dp[i-1][j],
dp[i][j-1],
dp[i-1][j-1]);
}
}
8

68

8
06

06

06
return dp[len1][len2];
00
0

60

60
}
26

26

12

12
1

31

void findMinEdits(char* doc1, char* doc2, char* doc3) {


03

03

03
30

int dist12 = editDistance(doc1, doc2);


03

03

03
0
23

23

23

23
int dist23 = editDistance(doc2, doc3);
int dist13 = editDistance(doc1, doc3);

printf("Edit distance between doc1 and doc2: %d\n", dist12);


printf("Edit distance between doc2 and doc3: %d\n", dist23);
printf("Edit distance between doc1 and doc3: %d\n", dist13);
int total_edits = (dist12 + dist23 + dist13) / 2;
printf("Minimum total edits needed: %d", total_edits);
}
8

68

68
06

06
00

00
60

60

int main() {
6

6
12

12

12

12
char doc1[MAX_LEN], doc2[MAX_LEN], doc3[MAX_LEN];
03

03

03

03
03

03

03

03
23

23

23

23

fgets(doc1, MAX_LEN, stdin);


doc1[strcspn(doc1, "\n")] = 0;

fgets(doc2, MAX_LEN, stdin);


doc2[strcspn(doc2, "\n")] = 0;
8

8
06

06

06

06

fgets(doc3, MAX_LEN, stdin);


60

60

60

60

doc3[strcspn(doc3, "\n")] = 0;
12

12

12

12

findMinEdits(doc1, doc2, doc3);


03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
00

00

00
0
return 0;
6

26

6
12

12

12
31
}
03

03

03
0
03

03

03

03
23

23

23

23
Status : Correct Marks : 10/10

2. Problem Statement

Liam is developing an advanced speech-to-text application to help users


convert spoken language into written text seamlessly. However, spoken
language often differs from its written counterpart due to added words,
omissions, or slight phrasing changes. Liam wants to calculate the
8

68

8
06

06

06
00

minimum edit distance between the spoken text and the written text, while
0

60

60
26

26

12

12
also identifying the specific differences between the two texts. Edit
1

31
03

03

03
operations like insertion, deletion and substitution each cost 1.
30
03

03

03
0
23

23

23

23
Example:

LISTEN
S I L E N T (in this, I remains same and EN remains same other all places
either one of 3 operations has performed, so the minimal cost is 4)

Input Format
8

68

68
06

06
00

00
60

60

The first line of input contains the string, representing the spoken text.
6

6
12

12

12

12
03

03

03

The next line of input contains the string, representing the written text. 03
03

03

03

03
23

23

23

23

Output Format
The output prints the single integer representing the minimal cost.

Refer to the sample output for formatting specifications.


Sample Test Case
8

8
06

06

06

06
60

60

60

60

Input: listen
12

12

12

12

silent
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
Output: 4
00

00

00
0
6

26

6
12

12

12
Answer

31
03

03

03
0
#include <stdio.h>
03

03

03

03
23

23

23

23
#include <string.h>

#define MAX_LEN 101

typedef struct {
char spoken[MAX_LEN];
char written[MAX_LEN];
int spokenLen;
int writtenLen;
8

68

8
06

06

06
} TextComparator;
00
0

60

60
26

26

12

12
1

31

void initComparator(TextComparator* tc, char* spk, char* wrt) {


03

03

03
30

strcpy(tc->spoken, spk);
03

03

03
0
23

23

23

23
strcpy(tc->written, wrt);
tc->spokenLen = strlen(spk);
tc->writtenLen = strlen(wrt);
}

int getMin(int a, int b, int c) {


if (a <= b && a <= c) return a;
if (b <= a && b <= c) return b;
return c;
8

68

68
06

06

}
00

00
60

60
6

6
12

12

12

12
int calculateEditDistance(TextComparator* tc) {
03

03

03

int dp[MAX_LEN][MAX_LEN]; 03
03

03

03

03
23

23

23

23

int i, j;

for(j = 0; j <= tc->writtenLen; j++) {


dp[0][j] = j;
}

for(i = 0; i <= tc->spokenLen; i++) {


dp[i][0] = i;
}
8

8
06

06

06

06
60

60

60

60

for(i = 1; i <= tc->spokenLen; i++) {


12

12

12

12

for(j = 1; j <= tc->writtenLen; j++) {


03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
if(tc->spoken[i-1] == tc->written[j-1]) {
00

00

00
0
dp[i][j] = dp[i-1][j-1];
6

26

6
12

12

12
31
} else {
03

03

03
0
int substitute = dp[i-1][j-1] + 1;
03

03

03

03
23

23

23

23
int insert = dp[i][j-1] + 1;
int del = dp[i-1][j] + 1;
dp[i][j] = getMin(substitute, insert, del);
}
}
}

return dp[tc->spokenLen][tc->writtenLen];
}
8

68

8
06

06

06
00
0

60

60
int main() {
26

26

12

12
1

31

TextComparator tc;
03

03

03
30

char spoken[MAX_LEN], written[MAX_LEN];


03

03

03
0
23

23

23

23
scanf("%s %s", spoken, written);

initComparator(&tc, spoken, written);


printf("%d\n", calculateEditDistance(&tc));

return 0;
}
8

68

68
06

06

Status : Correct Marks : 10/10


00

00
60

60
6

6
12

12

12

12
03

03

03

3. Problem Statement 03
03

03

03

03
23

23

23

23

You are given two strings of equal length. You are allowed to move any
character in the first string to the front (like a stack operation) as many
times as needed.

Your task is to find the minimum number of such moves required to


transform the first string into the second string.
8

Example:
06

06

06

06
60

60

60

60

Input
12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
ADCB //String A
00

00

00
0
6

26

6
12

12

12
ABCD //String B

31
03

03

03
0
03

03

03

03
Output:
23

23

23

23
3

Explanation:
ADCB - CADB //move C to the front
CADB - BCAD // move B to the front
BCAD - ABCD //move A to the front
8

68

8
06

06

06
00
0

60

60
26

26

12

12
Input Format
1

31
03

03

03
30
03

03

03
The first line contains the first string.
0
23

23

23

23
The second line contains the second string.
Output Format
If transformation is possible, print a single integer: the minimum number of
moves required.

If transformation is not possible, print the message: "The string cannot be


transformed"
8

68

68
06

06
00

00
60

60

Sample Test Case


6

6
12

12

12

12
Input: WYXZ
03

03

03

03
03

03

03

03
WXYZ
23

23

23

23

Output: 2
Answer
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

bool isTransformable(char* first, char* second) {


int freq1[256] = {0}, freq2[256] = {0};
8

8
06

06

06

06
60

60

60

60

if (strlen(first) != strlen(second)) return false;


12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
for (int i = 0; first[i]; i++) {
00

00

00
0
freq1[(unsigned char)first[i]]++;
6

26

6
12

12

12
31
freq2[(unsigned char)second[i]]++;
03

03

03
0
}
03

03

03

03
23

23

23

23
for (int i = 0; i < 256; i++) {
if (freq1[i] != freq2[i]) return false;
}

return true;
}

int getMinimumOperations(char* first, char* second) {


8

68

8
06

06

06
int count = 0;
00
0

60

60
int i = strlen(first) - 1;
26

26

12

12
1

31

int j = i;
03

03

03
30
03

03

03
0
23

23

23

23
while (i >= 0) {
if (first[i] != second[j]) {
while (i >= 0 && first[i] != second[j]) {
i--;
count++;
}
}
i--;
j--;
8

68

68
06

06

}
00

00
60

60
6

6
12

12

12

12
return count;
03

03

03

} 03
03

03

03

03
23

23

23

23

int main() {
char first[101], second[101];
scanf("%s", first);
scanf("%s", second);

if (isTransformable(first, second)) {
printf("%d\n", getMinimumOperations(first, second));
} else {
8

8
06

06

06

06

printf("The string cannot be transformed\n");


60

60

60

60

}
12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
return 0;
00

00

00
0
}
6

26

6
12

12

12
31
03

03

03
0
Status : Correct Marks : 10/10
03

03

03

03
23

23

23

23
4. Problem Statement

You are given a string. Your task is to form the longest possible palindrome
by rearranging or deleting characters from the given string.

A palindrome reads the same forward and backward.


8

68

8
06

06

06
You can use any number of characters from the input.
00
0

60

60
26

26

12

12
Only one character with odd frequency can be placed in the middle of the
1

31
03

03

03
30

palindrome.
03

03

03
0
23

23

23

23
Example:
Input:
ABBDAB

Output:
BABAB
8

68

68
06

06
00

00
60

60

Input Format
6

6
12

12

12

12
03

03

03

A single line containing a string s, consisting of only uppercase or lowercase


03
03

03

03

03
English letters.
23

23

23

23

Output Format
The output prints the longest palindrome that can be formed from the characters
of the given string.
Sample Test Case
Input: BCDBD
Output: BDCDB
8

8
06

06

06

06

Answer
60

60

60

60
12

12

12

12

#include <stdio.h>
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
#include <string.h>
00

00

00
0
6

26

6
12

12

12
31
int main() {
03

03

03
0
char s[101];
03

03

03

03
23

23

23

23
scanf("%100s", s);

int freq[256] = {0};


int len = strlen(s);

for (int i = 0; i < len; i++) {


freq[(unsigned char)s[i]]++;
}
8

68

8
06

06

06
00
0

60

60
char left[101] = {0};
26

26

12

12
1

31

int left_index = 0;
03

03

03
30

char mid = 0;
03

03

03
0
23

23

23

23
for (int c = 0; c < 256; c++) {
if (freq[c] > 0) {
if (freq[c] % 2 == 1) {
mid = (char)c;
}

for (int j = 0; j < freq[c] / 2; j++) {


8

68

68
06

06

left[left_index++] = (char)c;
00

00
60

60

}
6

6
12

12

12

12
}
03

03

03

} 03
03

03

03

03
23

23

23

23

left[left_index] = '\0';

printf("%s", left);

if (mid != 0) {
printf("%c", mid);
}
8

8
06

06

06

06

for (int i = left_index - 1; i >= 0; i--) {


60

60

60

60

printf("%c", left[i]);
12

12

12

12

}
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
printf("\n");
00

00

00
0
6

26

6
12

12

12
31
return 0;
03

03

03
0
}
03

03

03

03
23

23

23

23
Status : Correct Marks : 10/10

5. Problem Statement

You're building an AI-powered spell check assistant for a word processor


used by thousands of writers across the [Link] a user mistypes a
word, the software compares it to a dictionary word to suggest
8

68

8
06

06

06
00

corrections. The core of this feature is calculating how close the typed
0

60

60
26

26

word is to a valid dictionary word. You are tasked with writing a program

12

12
1

31
03

03

03
that computes the minimum number of operations required to convert one
30
03

03

03
0

word into another. The allowed operations are:


23

23

23

23
Insert a characterRemove a characterReplace a character
Input Format
The first line of input contains the string word1 representing the text by user.

The next line of input contains the string word2 representing the text from
dictionary.
8

68

68
06

06

Output Format
00

00
60

60
6

6
The output prints the single integer representing the the minimum number of
12

12

12

12
03

03

03

03
operations required to convert word1 to word2.
03

03

03

03
23

23

23

23

Refer to the sample output for formatting specifications.


Sample Test Case
Input: kitten
sitting
8

Output: 3
06

06

06

06
60

60

60

60

Answer
12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
#include <iostream>
00

00

00
0
#include <vector>
6

26

6
12

12

12
31
#include <string>
03

03

03
0
#include <algorithm>
03

03

03

03
23

23

23

23
using namespace std;

int editDistance(string word1, string word2) {


int n = [Link]();
int m = [Link]();

vector<vector<int>> dp(n+1, vector<int>(m+1, 0));


8

68

8
06

06

06
for (int i = 0; i <= n; i++) dp[i][0] = i;
00
0

60

60
for (int j = 0; j <= m; j++) dp[0][j] = j;
26

26

12

12
1

31
03

03

03
30
03

03

03
0
23

23

23

23
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (word1[i-1] == word2[j-1]) {
dp[i][j] = dp[i-1][j-1];
} else {
dp[i][j] = 1 + min({
min(dp[i-1][j], dp[i][j-1]),
dp[i-1][j-1]
});
8

68

68
06

06

}
00

00
60

60

}
6

6
12

12

12

12
}
03

03

03

03
03

03

03

03
23

23

23

23

return dp[n][m];
}

int main() {
string word1, word2;
cin >> word1 >> word2;

cout << editDistance(word1, word2) << endl;


return 0;
8

8
06

06

06

06

}
60

60

60

60
12

12

12

12

Status : Correct Marks : 10/10


03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
6. Problem Statement
00

00

00
0
6

26

6
12

12

12
31
Alex is a student at St. Joseph's High School and is working on a project to
03

03

03
0
03

03

03

03
convert one version of a document into another. In order to make the two
23

23

23

23
versions identical, Alex can perform three types of operations: insertion,
deletion, and substitution. Each operation comes with a cost, and Alex
wants to minimize the total cost of transforming the document. The costs
of each operation are as follows:
Insertion (adding a character): 3 units of costDeletion (removing a
character): 2 units of costSubstitution (replacing a character): 5 units of
cost
8

68

8
Alex needs your help to determine the minimum cost required to transform
06

06

06
00
0

60

60
the first document (doc1) into the second document (doc2) using a
26

26

12

12
1

31

combination of these operations. The goal is to figure out how Alex can
03

03

03
30
03

03

03
make the transformation at the lowest possible cost.
0
23

23

23

23
Input Format
The first input is a string doc1, representing the original document.

The second input is a string doc2, representing the target document.


Output Format
The output should be a single integer, representing the minimum cost required to
8

68

68
transform doc1 into doc2.
06

06
00

00
60

60
6

6
12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23

Refer to the sample output for formatting specifications.


Sample Test Case
Input: cat
rat
Output: 5
Answer
8

8
06

06

06

06

#include <stdio.h>
60

60

60

60

#include <string.h>
12

12

12

12

#define MAX_LEN 101


03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
typedef struct {
00

00

00
0
char doc1[MAX_LEN];
6

26

6
12

12

12
31
char doc2[MAX_LEN];
03

03

03
0
int len1;
03

03

03

03
23

23

23

23
int len2;
} DocTransform;
void initTransformer(DocTransform* dt, char* str1, char* str2) {
strcpy(dt->doc1, str1);
strcpy(dt->doc2, str2);
dt->len1 = strlen(str1);
dt->len2 = strlen(str2);
}
int getMin(int a, int b, int c) {
8

68

8
06

06

06
if (a <= b && a <= c) return a;
00
0

60

60
if (b <= a && b <= c) return b;
26

26

12

12
1

31

return c;
03

03

03
30

}
03

03

03
0
23

23

23

23
int calculateMinCost(DocTransform* dt) {
int dp[MAX_LEN][MAX_LEN];
int i, j;
const int INS_COST = 3;
const int DEL_COST = 2;
const int SUB_COST = 5;

for(j = 0; j <= dt->len2; j++) {


8

68

68
06

06

dp[0][j] = j * INS_COST;
00

00
60

60

}
6

6
12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23

for(i = 0; i <= dt->len1; i++) {


dp[i][0] = i * DEL_COST;
}

for(i = 1; i <= dt->len1; i++) {


for(j = 1; j <= dt->len2; j++) {

if(dt->doc1[i-1] == dt->doc2[j-1]) {
8

8
06

06

06

06

dp[i][j] = dp[i-1][j-1];
60

60

60

60

}
12

12

12

12

else {
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
00

00

00
0
int substitute = dp[i-1][j-1] + SUB_COST;
6

26

6
12

12

12
31
int insert = dp[i][j-1] + INS_COST;
03

03

03
0
int del = dp[i-1][j] + DEL_COST;
03

03

03

03
23

23

23

23
dp[i][j] = getMin(substitute, insert, del);
}
}
}

return dp[dt->len1][dt->len2];
}
8

68

8
06

06

06
int main() {
00
0

60

60
DocTransform dt;
26

26

12

12
1

31

char str1[MAX_LEN], str2[MAX_LEN];


03

03

03
30

int scan_result;
03

03

03
0
23

23

23

23
scan_result = scanf("%s", str1);
scan_result = scanf("%s", str2);

initTransformer(&dt, str1, str2);

int minCost = calculateMinCost(&dt);


8

68

68
06

06

printf("%d", minCost);
00

00
60

60
6

6
12

12

12

12
return 0;
03

03

03

} 03
03

03

03

03
23

23

23

23

Status : Correct Marks : 10/10

7. Problem Statement

Olivia is comparing two historical manuscripts, manuscript1 and


manuscript2, and wants to determine the minimum cost required to
transform manuscript1 into manuscript2 by performing a series of
8

8
06

06

06

06

operations. These operations can be insertion, deletion, or substitution of


60

60

60

60

characters, each with a specific cost. The cost of each operation is given
12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
as input. Write a program to calculate the minimum cost of transforming
00

00

00
0
one manuscript into another.
6

26

6
12

12

12
31
03

03

03
0
03

03

03

03
Input Format
23

23

23

23
The first line of input contains the string m1, representing manuscript 1.

The second line of input contains the string m2, representing manuscript 2.

The third line of input contains three integers representing the costs of the
operations: insertion, deletion, and substitution.
Output Format
8

68

8
The output prints the integer representing the minimum cost required to
06

06

06
00
0

60

60
transform manuscript1 into manuscript2.
26

26

12

12
1

31
03

03

03
30
03

03

03
0
23

23

23

23
Refer to the sample output for formatting specifications.
Sample Test Case
Input: book
back
4
3
8

68

68
5
06

06
00

00
60

60
6

6
Output: 10
12

12

12

12
03

03

03

Answer 03
03

03

03

03
23

23

23

23

#include <stdio.h>
#include <string.h>
#define MAX_LEN 101
typedef struct {
char text1[MAX_LEN];
char text2[MAX_LEN];
int len1;
int len2;
int insCost;
8

8
06

06

06

06

int delCost;
60

60

60

60

int subCost;
12

12

12

12

} Manuscript;
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
void initManuscript(Manuscript* m, char* str1, char* str2, int ins, int del, int sub)
00

00

00
0
{
6

26

6
12

12

12
31
strcpy(m->text1, str1);
03

03

03
0
strcpy(m->text2, str2);
03

03

03

03
23

23

23

23
m->len1 = strlen(str1);
m->len2 = strlen(str2);
m->insCost = ins;
m->delCost = del;
m->subCost = sub;
}

int getMin(int a, int b, int c) {


if (a <= b && a <= c) return a;
8

68

8
06

06

06
if (b <= a && b <= c) return b;
00
0

60

60
return c;
26

26

12

12
1

31

}
03

03

03
30
03

03

03
0
23

23

23

23
int calculateMinCost(Manuscript* m) {
int dp[MAX_LEN][MAX_LEN];
int i, j;
for(j = 0; j <= m->len2; j++) {
dp[0][j] = j * m->insCost;
}
for(i = 0; i <= m->len1; i++) {
dp[i][0] = i * m->delCost;
}
8

68

68
06

06

for(i = 1; i <= m->len1; i++) {


00

00
60

60

for(j = 1; j <= m->len2; j++) {


6

6
12

12

12

12
if(m->text1[i-1] == m->text2[j-1]) {
03

03

03

dp[i][j] = dp[i-1][j-1]; 03
03

03

03

03
23

23

23

23

} else {
int substitute = dp[i-1][j-1] + m->subCost;
int insert = dp[i][j-1] + m->insCost;
int del = dp[i-1][j] + m->delCost;

dp[i][j] = getMin(substitute, insert, del);


}
}
}
8

8
06

06

06

06
60

60

60

60

return dp[m->len1][m->len2];
12

12

12

12

}
03

03

03

03
03

03

03

03
23

23

23

23
68

68

68
06
00

00

00
0
int main() {
6

26

6
12

12

12
31
Manuscript m;
03

03

03
0
char str1[MAX_LEN], str2[MAX_LEN];
03

03

03

03
23

23

23

23
int insCost, delCost, subCost;
scanf("%s", str1);
scanf("%s", str2);
scanf("%d", &insCost);
scanf("%d", &delCost);
scanf("%d", &subCost);
initManuscript(&m, str1, str2, insCost, delCost, subCost);
int minCost = calculateMinCost(&m);
printf("%d", minCost);
8

68

8
06

06

06
00
0

60

60
return 0;
26

26

12

12
1

31

}
03

03

03
30
03

03

03
0
23

23

23

23
Status : Correct Marks : 10/10
8

68

68
06

06
00

00
60

60
6

6
12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23
8

8
06

06

06

06
60

60

60

60
12

12

12

12
03

03

03

03
03

03

03

03
23

23

23

23

You might also like