Skip to content

Instantly share code, notes, and snippets.

@tksmaru
Created February 12, 2012 12:23
Show Gist options
  • Save tksmaru/1808246 to your computer and use it in GitHub Desktop.
Save tksmaru/1808246 to your computer and use it in GitHub Desktop.
SRM241 div1-score250
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()]);
}
}
@tksmaru
Copy link
Author

tksmaru commented Feb 13, 2012

権限名に使用している単語が被ってたりすると上手く検出できない。
ので、allowedDataは単語単位で分解してequalsメソッドで比較した方が良い。

@tksmaru
Copy link
Author

tksmaru commented Feb 13, 2012

ちなみに、引数チェックは敢えてしていません。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment