D:/

Topcoderで気分転換-SRM241(div1 score250)-

SRM: 241(div1 score250) Statement

You are working on a large database that holds information about several different aspects of your company, such as customers, partners, prospects, employees, products, etc. Every user in the system has access to one or more types of data. For instance, a human resources worker might only have access to employee records, while a sales person might have access to prospects, customers, and products.

You are in charge of writing reports that summarize large volumes of this information. However, since the reports may contain more than one type of data, you need to be determine which users should be allowed to view that report. In this case, assume that a user has permission to view a report if and only if they have permission to view all of the types of data contained in that report.

You are given a list of usernames in String[] userNames. You are given a list of what data types each user can access in String[] allowedData, where each element of allowedData is a space-delimited list of the permitted data types for that user. Finally, you are given a String[] reportData, where each element of report indicates a type of data included in the report.

You are to return a String[] indicating the user names of those users who should be able to access the report. The list should be returned in alphabetical order.

超意訳

  • 引数reportData指定した権限を全て持っているユーザを一覧で出してね。

書いたコード


反省

  • 所要時間: 約15分
  • allowedDataを無駄に分解しようとしてコードを書くのに時間がかかった。
  • String#contains(CharSequence s) を思い出したら早かった。
  • EclipseCoderプラグインを使うと単体テストを自動生成してくれるので、コードを書くことのに集中できて楽。

修正

よくよく考えてみたら、containsだと上手くユーザを検出できない可能性がある。
ということで下記のように修正。