Created
February 12, 2012 12:23
-
-
Save tksmaru/1808246 to your computer and use it in GitHub Desktop.
SRM241 div1-score250
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.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
//SRM241 | |
public class ReportAccess { | |
public String[] whoCanSee(String[] userNames, String[] allowedData, | |
String[] reportData) { | |
List<String> users = new ArrayList<String>(); | |
int requires = reportData.length; | |
for (int i = 0; i < allowedData.length; i++) { | |
int count = 0; | |
for (String report : reportData) { | |
if (allowedData[i].contains(report)) { | |
count++; | |
} | |
} | |
if (count == requires) { | |
users.add(userNames[i]); | |
} | |
} | |
Collections.sort(users); | |
return users.toArray(new String[users.size()]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
権限名に使用している単語が被ってたりすると上手く検出できない。
ので、allowedDataは単語単位で分解してequalsメソッドで比較した方が良い。