Question: 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.

i have a code which i'm not sure why it's not working,my 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!