Find the Sequence of Strings Appeared on the Screen

class Solution {
public List<String> stringSequence(String target) {
List<String> list = new ArrayList<>();
StringBuilder sb = new StringBuilder();
for(char c : target.toCharArray()){
if(list….


This content originally appeared on DEV Community and was authored by Prashant Mishra

class Solution {
    public List<String> stringSequence(String target) {
        List<String> list  = new ArrayList<>();
        StringBuilder sb = new StringBuilder();
        for(char c : target.toCharArray()){
            if(list.size()!=0){
                sb.append(list.get(list.size()-1));
            }
            sb.append('a');
            list.add(sb.toString());
            for(char i = 'a'+1;i<=c;i++){
                sb.deleteCharAt(sb.length()-1);
                sb.append(i);
                list.add(sb.toString());
            }
            sb.setLength(0);
        }
        return list;
    }
}


This content originally appeared on DEV Community and was authored by Prashant Mishra


Print Share Comment Cite Upload Translate Updates
APA

Prashant Mishra | Sciencx (2024-10-20T04:13:47+00:00) Find the Sequence of Strings Appeared on the Screen. Retrieved from https://www.scien.cx/2024/10/20/find-the-sequence-of-strings-appeared-on-the-screen/

MLA
" » Find the Sequence of Strings Appeared on the Screen." Prashant Mishra | Sciencx - Sunday October 20, 2024, https://www.scien.cx/2024/10/20/find-the-sequence-of-strings-appeared-on-the-screen/
HARVARD
Prashant Mishra | Sciencx Sunday October 20, 2024 » Find the Sequence of Strings Appeared on the Screen., viewed ,<https://www.scien.cx/2024/10/20/find-the-sequence-of-strings-appeared-on-the-screen/>
VANCOUVER
Prashant Mishra | Sciencx - » Find the Sequence of Strings Appeared on the Screen. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/20/find-the-sequence-of-strings-appeared-on-the-screen/
CHICAGO
" » Find the Sequence of Strings Appeared on the Screen." Prashant Mishra | Sciencx - Accessed . https://www.scien.cx/2024/10/20/find-the-sequence-of-strings-appeared-on-the-screen/
IEEE
" » Find the Sequence of Strings Appeared on the Screen." Prashant Mishra | Sciencx [Online]. Available: https://www.scien.cx/2024/10/20/find-the-sequence-of-strings-appeared-on-the-screen/. [Accessed: ]
rf:citation
» Find the Sequence of Strings Appeared on the Screen | Prashant Mishra | Sciencx | https://www.scien.cx/2024/10/20/find-the-sequence-of-strings-appeared-on-the-screen/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.