import java.io.*; import java.util.*; class GFG { static void printSub(String str, String curr, int index) { if(index == str.length()) { System.out.print(curr+" "); return; } printSub(str, curr, index + 1); printSub(str, curr+str.charAt(index), index + 1); } public static void main(String [] args) { String str = "ABC"; printSub(str, "", 0); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter