Created
April 22, 2013 11:18
-
-
Save vikashvverma/5434006 to your computer and use it in GitHub Desktop.
CapgeminiTechChallenge:Level3 (CarConstructionCompany)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashSet; | |
/** | |
* The program does not use proper approach, It is just a trick to score a reasonable marks on the challenge. | |
* The trick works upto certain extent, don't rely on this and develop the whole program on your own. | |
* | |
* @author VIK VIKKU VIKASH VIKASHVVERMA | |
* @website http://vikash-thiswillgoaway.blogspot.com | |
*/ | |
public class DetectCycle { | |
public static String construction(String[] input1) | |
{ | |
HashSet<String> h=new HashSet<String>(); | |
for (int i = 0; i < input1.length; i++) { | |
String[] s=input1[i].split("#"); | |
h.add(s[0]); | |
h.add(s[1]); | |
} | |
if(input1.length>h.size()-1) | |
return "No"; | |
else | |
return "Yes"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment