Skip to content

Instantly share code, notes, and snippets.

@tksmaru
Created February 13, 2012 00:16
Show Gist options
  • Save tksmaru/1812001 to your computer and use it in GitHub Desktop.
Save tksmaru/1812001 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++) {
String[] splited = allowedData[i].split(" ");
int count = 0;
for (String allowed : splited) {
for (String report : reportData) {
if (allowed.equals(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