Java program to print all substring of length 3 from a given string.
Answers
Answered by
0
Answer:
class SubstringsOfStringMain
{
public static void main(String args[])
{
String str="abc";
System.out.println("All substring of abbc are:");
for (int i = 0; i < str.length(); i++) {
for (int j = i+1; j <= str.length(); j++) {
System.out.println(str.substring(i,j));
}
}
}
}
Explanation:
output :
All substring of abc are:
a
ab
abc
b
bc
c
=> Solution is of o(n^3) time complexity.
Similar questions
Math,
6 hours ago
Math,
6 hours ago
Math,
6 hours ago
Computer Science,
12 hours ago
Social Sciences,
7 months ago
Business Studies,
7 months ago