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


how to divide strings

Kevin has a string S consisting of N lowercase English letters.

Kevin wants to split it into 4 pairwise different non-empty parts. For example, string "happynewyear" can be splitted into "happy", "new", "ye" and "ar". He can't delete any characters or change the order of the characters.

Help Kevin and find if there exist at least one possible spliting.

Input format:

The first line of input will contain an integer T, denoting the number of test cases. Each of the next T lines contains a string S.

Output format:

For every test case output "YES" if it is possible to split the string and "NO" otherwise.


1 ≤ T ≤ 100 1 ≤ N ≤ 1000 N ≤ 20 in test data worth 40% of all points Sample Input(Plaintext Link) 2 ababca aaabb Sample Output(Plaintext Link) YES NO

asked 03 Jan '16, 21:24

arpit728's gravatar image

accept rate: 10%

dont answer this question its a question from ongoing contest in hackerearth


answered 03 Jan '16, 22:37

tihorsharma123's gravatar image

accept rate: 15%

Answer is hidden as author is suspended. Click here to view.

answered 04 Jan '16, 03:49

sarvagya3943's gravatar image

accept rate: 36%


answered 20 Jan '16, 11:33

computaholics's gravatar image

accept rate: 11%

Here is a c program to split a string. We can use the same algorithm to solve this c program also.


answered 07 Apr '17, 13:59

gmiller's gravatar image

accept rate: 0%

Answer is hidden as author is suspended. Click here to view.

answered 09 Apr '17, 15:08

ardentcoder's gravatar image

accept rate: 15%

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: 03 Jan '16, 21:24

question was seen: 6,063 times

last updated: 09 Apr '17, 15:08