Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a program to generate all possible substrings of a given string.

Medium

Problem Statement

Create a program to generate all possible substrings of a given string.

Sample Input

"abc"

Sample Output

[ 'a', 'ab', 'abc', 'b', 'bc', 'c' ]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
// Generate all possible substrings of a string function getSubstrings(str) { } console.log(getSubstrings("abc"));
Log in or sign up to run or submit your code.Log inSign up
Input
"abc"
Expected Output
[ 'a', 'ab', 'abc', 'b', 'bc', 'c' ]