You are not logged in. Please login at to post your questions!


String question Can anyone give me some hint of this question?? Contest not running..

asked 14 Jun '18, 00:29

sna902055's gravatar image

accept rate: 7%

edited 14 Jun '18, 00:30

The problem basically asks you are given a string, if you can choose a subset of characters such that when taken in same order as present in the main string they have same beginning and end character. This can be easily solved using bitmasking. I won't explain much. If you want you can have a look at my code. If you don't know bitmasking learn it and then attempt this.

 for(int mask=0;mask<(1ll<<n);mask++)
    if(mask==0) continue;
       string temp="";
        if(mask&(1ll<<i)) temp+=s[i];

        if(temp[0]==temp[temp.size()-1]) ans++;


answered 14 Jun '18, 01:37

soham1234's gravatar image

accept rate: 22%

Got it..... thank you...

(14 Jun '18, 06:28) sna9020555★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 14 Jun '18, 00:29

question was seen: 97 times

last updated: 14 Jun '18, 06:28