Skip to content

Commit da6ee49

Browse files
committed
lec17
1 parent dccf3c6 commit da6ee49

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Strings/Substrings.class

160 Bytes
Binary file not shown.

Strings/Substrings.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,28 @@ static void printAllSubstrings(String str)
1515

1616
}
1717

18+
static void printAllSubstringsReverse(String str)
19+
{
20+
21+
int n=str.length();
22+
for(int st=n-1;st>=0;st--)
23+
{
24+
for(int en=st+1;en<=n;en++)
25+
{
26+
System.out.println(str.substring(st, en));
27+
}
28+
}
29+
30+
}
31+
1832

1933
public static void main(String[] args) {
2034

2135
String str="abc";
2236

23-
printAllSubstrings(str);
37+
// printAllSubstrings(str);
2438

39+
printAllSubstringsReverse(str);
2540

2641

2742
}

0 commit comments

Comments
 (0)