Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i have a code which i'm not sure why it's not working, i'm getting an error. my entire code looks like this import java.io.*; class

i have a code which i'm not sure why it's not working, i'm getting an error.

image text in transcribedmy entire code looks like this

import java.io.*;

class Solution{

int c[][];

String d[][];

int m,n;

Solution(){

c = new int[1000][1000];

d = new String[1000][1000];

}

void solve(String a, String b ){

this.m = a.length();

this.n = b.length();

// As new objects of c and b is already created during constructor call then, we don't have to

// initilialize first row and column, They are already 0.

// b[m+1][n+1]

// Assuming

for(int i =1;i

for(int j = 1;j

if(b.charAt(i-1) == a.charAt(j-1))

{

c[i][j] = c[i-1][j-1]+1;

d[i][j]= "LT";

} else if(c[i-1][j]>=c[i][j-1])

{

c[i][j] = c[i-1][j];

d[i][j]= "U ";

}

else {

c[i][j] = c[i][j-1];

d[i][j]= "L ";

}

}

}

// Printing the result

StringBuffer res = new StringBuffer();

for(int i =0;i

for(int j = 0;j

res.append(c[i][j]+" ");

}

res.append(" ");

}

System.out.println(res);

int l = m, k =n;

while(l

if(b.charAt(l-1) == a.charAt(k-1)){

res.setCharAt(l, res.charAt(l)+" "+ d[l-1]);

l--;

k--;

}

else if(c[l-1][k]>c[l][k-1])

l--;

else k--;

}

// System.out.println(res.reverse());

}

}

class GFG {

public static void main (String[] args) {

Solution s = new Solution();

String x = "BAABCDCA";

String y = "BCAABCDA";

s.solve(x,y);

}

}

94 res.append ("n" 95 96 97 98 System.out.println(res) 100 101 102 103 104 105 106 107 108 109 no suitable method found for setCharAt int,String) method AbstractStringBuilder.setCharAt(int,char) is not applicable (argument mismatch; String cannot be converted to char) method StringBuffer.setCharAt(int,char) is not applicable (argument mismatch; String cannot be converted to char) Array concatenated with String (Alt-Enter shows hints) 112l--; 113 114 115 116 118 else if (cl-1] [k]>cIll [k-1]) 119 120-i 121 122 else k-- 123 124

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

1. The evaluation results can be used to change the program.

Answered: 1 week ago

Question

5. To determine the financial benefits and costs of the program.

Answered: 1 week ago