From 84b2b8ad9411ffeded1ba81168fcc9202a0a2794 Mon Sep 17 00:00:00 2001 From: Nimit Arora Date: Sun, 1 Oct 2017 23:31:01 +0530 Subject: [PATCH] Added Algorithm to Return Subsequences --- Misc/ReturnSubsequence.java | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Misc/ReturnSubsequence.java diff --git a/Misc/ReturnSubsequence.java b/Misc/ReturnSubsequence.java new file mode 100644 index 00000000..ef3aaed0 --- /dev/null +++ b/Misc/ReturnSubsequence.java @@ -0,0 +1,59 @@ +/* +This program will return all the subsequences of the input string in a string array; +Sample Input: +abc +Sample Output: +"" ( Empty String ) +c +b +bc +a +ac +ab +abc + + */ + +import java.util.Scanner; + +public class ReturnSubsequence { + /* + Main function will accept the given string and implement return subsequences function + */ + public static void main(String[] args) { + System.out.println("Enter String: "); + Scanner s=new Scanner(System.in); + String givenString=s.next(); //given string + String[] subsequence=returnSubsequence(givenString); //calling returnSubsequence() function + System.out.println("Subsequences : "); + for(int i=0;i