This is my first attempt to create a set of two challenges for HackerRank. If you are interested in generating a new challenge you should try the Challenge Guidelines link and read all about how to proceed.
After reading the guidelines I created the following information for the “New, Duplicate or In Segment” challenge:
Challenge Name: New, Duplicate or In Segment
Description: Determine if integer is new, a duplicate or part of a segment.
Problem Statement: Within the specified range label each received integer as “New” if the integer is being processed for the first time, “Duplicate” is the integer is not in a segment but has been processed before or “In segment” if the integer is part of a segment of two or more integers.
Input Format: A line with the number of test cases T followed by a line with two integers representing the low L and high H range of the expected values. The next line contains the count C of input integers followed by the actual integers.
1 <= T <= 100
1 <= L < H <= 1000
1 <= C <= 2000
L <= I <= H
Output Format: For each integer in the set print the integer I followed by the string “New” if the integer has not been processed before, “Duplicate” if the integer has been processed before but is not in a segment and “In segment” if the integer is in a segment of two or more monotonically ascending values.
Sample Input / Output and Explanation:
1 1 7 7 6 3 5 7 3 5 3 New New In segment In segment Duplicate In segment Duplicate
Six and 3 are new values. Number 5 creates a new segment [5:6]. Number 7 extends segment [5:7]. Number 3 is a duplicate. Number 5 is in segment [5:7] and finally number 3 is a duplicate.
1 1 19 9 12 2 14 15 5 9 8 16 6 New New New In segment New New In segment In segment In segment
The first three numbers are new. Number 15 creates a new segment [14:15], Numbers 5 and 9 are new. Number 8 creates a new segment [8:9]. Number 16 expands segment [14:16] and number 6 creates a new segment [8:9].
Additional input test cases:
Following instructions, I created a few () test cases naming them input00.txt, input01.txt, … and zipped them into input_files.zip. The zipped file was then uploaded. The process was repeated with output files named output00.txt, output01.txt, … and zipped them into output_files.zip.
Given the constraints an array of the specified number of entries should be made available. Select a value to indicate the integer has been processed and another to indicate it has not been processed yet. An array of Boolean seems to fit well. When an integer is presented determine if the integer is new or duplicate. One must determine if the integer is part of a segment. The definition of a segment includes both ends [included : included]. Both ends of the array are checked and a third test takes care of segments within the ends.
I became somewhat confused about the procedure of submitting a new challenge (not a contest). My confusion came about by using the following link which I found in the HackerRank web site.
How do I create challenges on HackerRank?
Check out our challenge creation guidelines link to make your own private challenges.
Once you’re familiar with our platform, we’re always looking for talented problem setters and testers!
Apply to be a paid contributor here.
Towards the bottom of the page I encountered the following text:
Can I create challenges for HackerRank?
If you would like to become a paid contributor and have your challenge showcased in a HackerRank contest, then please complete this support form to submit your challenge. We are open to challenges in any domain that involves programming, for example Algorithms, Artificial Intelligence, Machine Learning, Database.
I decided that before going any further I could ask for a go / no go response. Sent a message from the website and will wait for a response.
If you have comments or questions regarding this or any other post in this blog, please do not hesitate and send me a message. Will reply as soon as possible and will not use your name unless you explicitly allow me to do so.
Follow me on Twitter: @john_canessa