| You are working as an intern at Talilulu University. Your task is to make a program that will help people to enroll in classes at the university. You are given a String[] names containing the names of the classes and a int[] spaces containing the number of spaces currently available in each class. The i-th element of names corresponds to the i-th element of spaces. You are also given a String[] queries containing the sequence of enrollment requests. Each element of queries is the name of the class in which a student wants to enroll.
Go through the elements of queries in order, and for each one, enroll the student in the class if there's room, or reject the request if the class does not exist or does not have any space available. Return a String[] containing the responses for each request. The i-th element of the String[] is the response to the i-th query. It should be "GOOD" if the enrollment is accepted, "NOT GOOD" if there is no available space in the requested class, or "DOES NOT EXIST" if the class does not exist (all quotes for clarity). |
| {"QCDTBCZICBJGQCCKIWXN",
"LFAYDMBGLNXWNNDLHARQLYLWYJWMWOZ",
"KPYATSAMTTKX",
"HCNJGXTYCLPRENVMJPFEPVOYMTHXACMKTLGPQSEUJONXNZAVMR",
"QADJYGPJ",
"WVAGAZUCBG",
"NHCKOMRNBSYRCKLNLCEOM",
"SXXHKMNERPHPEQE",
"JJUOCTOLFRJLJERFIXTCE",
"SHQHEJGLUEWJIWPTSKTOPZTBVFFL"} | {2, 1, 41, 5, 1, 0, 1, 13, 11, 9} | {"NHCKOMRNBSYRCKLNLCEOM",
"MTLRHPNKFNEXQQOWYERECRZXT",
"QADJYGPJ",
"WVAGAZUCBG",
"EWWVWQZQNXEJGZJGZEVHKE",
"QADJYGPJ",
"IBQEMIBIGLVZLAOAYVPOMWZI",
"JTFOEIPGOAHSGLYMQSCTVVMDINGURUWEZTHJFWUYAWBLAD",
"ZRVMTHVAXCXJQPN",
"QCDTBCZICBJGQCCKIWXN",
"BVYUCAHSOBCBEFDEXWXFTKURXTIFDXXIDNBUPOPAWCBZHQY",
"WVAGAZUCBG",
"RVEJYNRBCOWRJBZHRTNQXROHWQOODMVDMVJDRNKWRGLXWWGPPW",
"QADJYGPJ",
"TYOMTKEVXMAVJBFBFDFOWARMZXSBUEMMQUWUNPSW",
"SXXHKMNERPHPEQE",
"JJUOCTOLFRJLJERFIXTCE",
"SXXHKMNERPHPEQE",
"SHQHEJGLUEWJIWPTSKTOPZTBVFFL",
"JJUOCTOLFRJLJERFIXTCE",
"QCDTBCZICBJGQCCKIWXN",
"SXXHKMNERPHPEQE",
"JJUOCTOLFRJLJERFIXTCE",
"NJQBVNXCZZNLWM",
"JJUOCTOLFRJLJERFIXTCE",
"QADJYGPJ",
"LFAYDMBGLNXWNNDLHARQLYLWYJWMWOZ"} |
| Returns:
{"GOOD",
"DOES NOT EXIST",
"GOOD",
"NOT GOOD",
"DOES NOT EXIST",
"NOT GOOD",
"DOES NOT EXIST",
"DOES NOT EXIST",
"DOES NOT EXIST",
"GOOD",
"DOES NOT EXIST",
"NOT GOOD",
"DOES NOT EXIST",
"NOT GOOD",
"DOES NOT EXIST",
"GOOD",
"GOOD",
"GOOD",
"GOOD",
"GOOD",
"GOOD",
"GOOD",
"GOOD",
"DOES NOT EXIST",
"GOOD",
"NOT GOOD",
"GOOD" } | |
|