Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:54:43+00:00 2026-05-28T16:54:43+00:00

Given a string: String words = Mary had a little lamb; how to obtain

  • 0

Given a string:

String words = "Mary had a little lamb";

how to obtain a combination of sentence fragments while the order of occurrence of words in the original sentence is maintained ???

example:

{'Mary had a little lamb'}
{'Mary had a little', 'lamb'}
{'Mary had a', 'little lamb'}, {'Mary had a', 'little', 'lamb'}
{'Mary had', 'a little lamb'}, {'Mary had', 'a little', 'lamb'}, {'Mary had', 'a', 'little lamb'}, {'Mary had', 'a', 'little', 'lamb'}
{'Mary', 'had a little lamb'}, {'Mary', 'had a little', 'lamb'}, {'Mary', 'had a', 'little lamb'} and so on...

Thanks in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:54:44+00:00Added an answer on May 28, 2026 at 4:54 pm

    Think about it this way:

    Mary <1> had <2> a <3> little <4> lamb
    

    Each of these <number>s can be either true or false. If it is true, then you cut the sentence in that location.

    So, if you have n+1 words, your problem gets reduced to going through binary representation of numbers with n bit, that is from 0 to 2^n-1

    Examples:

    0110 -> {'Mary had', 'a', 'little lamb'}
    1111 -> {'Mary', 'had', 'a', 'little', 'lamb'}
    0001 -> {'Mary had a little', 'lamb'}
    1011 -> {'Mary', 'had a', 'little', 'lamb'}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I count the words of a sentence given as string? We are
Given a string of words separated by whitespace. Need to replace whitespaces with comma
More specifically, I'm trying to check if given string (a sentence) is in Turkish.
I need to match all the whole words containing a given a string. string
Suppose you have a dictionary that contains valid words. Given an input string with
The given string is something like: words words {{{value}}} some other words {{{value2}}} I'm
I'm trying to wrap the words of a given string and display it in
I'm trying to compress any given string to a shorter version, copy paste-able compressed
How can I drop all tables whose names begin with a given string? I
Is there a way to determine the display length of a given string (in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.