Getting wrong values of ascii values

package DSA;

import java.util.*;

public class Getsequence {

public static void main(String[] args) {
	System.out.println(getss("ab"));
}

public static ArrayList<String> getss(String str) {
	if (str.length() == 0) {
		ArrayList<String> baseResult = new ArrayList();
		baseResult.add(" ");
		return baseResult;
	}
	char cc = str.charAt(0);
	String ros = str.substring(1);
	ArrayList<String> myResult = new ArrayList();
	ArrayList<String> recResult = getss(ros);
	for (int i = 0; i < recResult.size(); i++) {
		for (int j = 0; j < str.length(); j++) {
			char character = str.charAt(j);
			int ascii = (int) character;
			myResult.add(ascii + cc + recResult.get(i));
		}
			myResult.add(recResult.get(i));
			myResult.add(cc + recResult.get(i));
		}
	return myResult;
}

}

can u pls send me the contest id and problem id of the question

1 Like

getting subsequence of the string with ascii value using get method in recursion

ok
i’m ready to help u
pls just mention the contest id and problem no.

without question how i know the sequence of the o/p

the question is that we have been given a string 'abc" and we have to find the subsequence of the string like " " " , β€œa”,β€œb”,β€œc”,β€œab”…"
with ascii value like β€œβ€ ", β€œa”,β€œ94”,β€œ94b” … here the no are ascii value… and it is question of the recursion lecture under get subsequence topic

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.