New, Duplicate or in Sequence – Part 2

I decided to complete the continuation of the HackerRank challenge that I put together. This is a follow up on my post New, Duplicate or in Segment.  Regarding the previous challenge, I need to get back to HackerRank. A member of their team sent me an invitation on Google Hangouts so the ball is in my court. Have been very busy this week so will be calling them over the weekend. If that plan does not work, I will try Monday. I believe there are several hours difference between us.

I am not going to provide a solution for this challenge but will provide the requirements at this time.

The challenge is named “New, Duplicate or in Segment – Part 2”. The requirements are as follows:

Given a set of integers indicate if the next number is new, is an isolated duplicate, or is part of a sequence. Each response needs to display the number or numbers in case the integer falls in a sequence / range. If the new or duplicate number becomes a continuous monotonically ascending sequence then the ends of the sequence must be displayed.

For example, given the following set of integers:

1
1 8
10
3 6 6 1 3 4 2 7 8 5

The responses would be:

New 3
New 6
Duplicate 6
New 1
Duplicate 3
Segment [3:4]
Segment [1:4]
Segment [6:7]
Segment [6:8]
Segment [1:8]

For the following set of integers:

1
1 8
8
1 8 2 7 3 6 4 5

The responses would be as follows:

New 1
New 8
Segment [1:2]
Segment [7:8]
Segment [1:3]
Segment [6:8]
Segment [1:4]
Segment [1:8]

The expected constraints are:

 

1 <= T <= 200

1 <= L < H <= 10000

1 <= C <= 10000

L <= integer <= H

T is the number of test cases per pass. L is the lowest integer value expected. H is the highest integer value expected. C is the count of integers in a test case. The last line contains a space separated set of C integers.

After talking with HackerRank this weekend, I will update both challenges as needed to conform with the submission requirements and hopefully will appear on their site in the near future.

If you have comments or questions regarding this or any other post in this blog, please do not hesitate and leave a message at the end of this post. I will respond as soon as possible.

Enjoy;

John

Follow me on Twitter:  @john_canessa

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.