联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp2

您当前位置:首页 >> Database作业Database作业

日期:2019-12-11 09:52

FINRA Engineer Questionnaire


Within this document are four different questions. Each question is structured in the following manner:

1)Premise

- Contains any needed background information

2)Request

- The actual question, what you are to solve

3)Notes

- A space if you feel like including notes of any kind for the given question

Please place your answer for each question in a separate file, following this naming convention:

FINRA_Qn.txt, where n = the question number (i.e., 1, 2 ...). So the file for the first question should be named ‘FINRA_Q1.txt’

Reponses can be code or pseudocode, with higher preference given to actual coded solutions. If a specific language is not requested by the question, please indicate the chosen language within a comment at the top of your solution. If you feel it necessary, add comments to parts of your solutions.


When complete, please package everything together and send email responses to the designated POCs.


Premise:

You have a table with one column, `original_date`, of datatype string

ORIGINAL_DATE

20190825

20190826

20190827

20190828

20190829

20190830

20190831

20190901


Question:

Write a (preferably hive) SQL query to calculate two more columns –

1)`end_of_week ` - the date of the next Sunday from `original_date`. If `original_date` is already a Sunday, this field should be the same value

2)`end_of_month ` - the value of the end of month date

An acceptable solution is one which works for any valid date in the string format of `original_date`.


Desired Result:

ORIGINAL_DATEEND_OF_WEEKEND_OF_MONTH

201908252019082520190831

201908262019090120190831

201908272019090120190831

201908282019090120190831

201908292019090120190831

201908302019090120190831

201908312019090120190831

201909012019090120190930


Additional Info:

20190825 is a Sunday, so the `end_of_week` for that value is still that same date.

20190827 is a Tuesday, and the next Sunday is on 20190901

Notes:


Premise:

You have a table `Activity`, with fields `ID`, `start_time`, and `end_time`. These fields are all of datatype string.

IDSTART_TIMEEND_TIME

10010:0012:00

10010:1512:30

10012:1512:45

10013:0014:00

20010:1510:30


Question:

Write a (preferably hive) SQL query to create a new field `group_id` which identifies records within each `ID` that have overlapping `start_time` and `end_time` intervals. An acceptable solution will have a unique `group_id` for each `ID` and overlapping set of intervals.

Desired Example:

IDSTART_TIMEEND_TIMEGROUP_ID

10010:0012:001

10010:1512:301

10012:1512:451

10013:0014:002

20010:1510:303


Additional Info: For a given `ID`, if any of its intervals overlap then the corresponding records belong to the same group, and thus should have the same `group_id`. A record A overlaps another record B when A’s `start_time` and/or `end_time` is between B’s `start_time` and `end_time`.


In the example, `ID` = 100 has four intervals. The first three overlap => the second record overlaps with the first (the `start_time` of 10:15 is between the `start_time` and `end_time` of 10:00 to 12:00) and the third overlaps with the second (the `start_time` of 12:15 is between the `start_time` and `end_time` of 10:15 to 12:30). Because of this, they all have the same `group_id` of 1. The fourth interval for `ID` = 100 does not overlap any of the other intervals within that `ID`, and so it becomes its own group with a new `group_id`. The last record has a completely different `ID` and so it starts a third group also with a new `group_id`.

Notes:

Premise:

Tracy has a file that contains a list of actors and the movies in which they acted. She wants to know the top 10 actors from her list whom have acted in the most movies.


ACTOR_NAMEMOVIE_NAME

Leonardo DiCaprioThe Revenant

Samuel L. JacksonPulp Fiction

Tom CruiseMission Impossible

Leonardo DiCaprioThe Great Gatsby

Question:

Write code (or pseudocode) in your favorite programming language to display the 10 actors appearing in the most movies, and the count of movies in which they have acted. If there are less than 10 actors in her list, display all of them.


Consider all scenarios - such as, if two actors have acted in the same number of movies, they will have the same rank.


Notes:

Premise:

Adam is so good at playing arcade games that he will win at every game he plays. One fine day as he was walking on the street, he discovers an arcade store that pays real cash for every game that the player wins - however, the store will only pay out once per game. The store has 10 games for which they will pay winners, and each game has its own completion time and payout rate. Thrilled at the prospect of earning money for his talent, Adam walked into the store only to realize that the store closes in 2 hours (exactly 120 minutes). Knowing that he cannot play all the games in that time, he decides to pick the games that maximize his earnings

GAMECOMPLETION_TIME (in minutes)PAYOUT_RATE

Pac-man75$250

Speed Racer45$280

Pump it Up30$150

Space Invaders35$120

Mario Bros30$200

Mortal Kombat15$100

Atari Breakout60$300

Super Tetris90$350

Star Wars20$110

Street Fighter II10$90


Question:

Write code (or pseudocode) in your favorite programming language to help Adam pick the sequence(s) of games that earn him the most money?.


Then, assume you have a variable list of games and their payout rates. What is the best way to pick the games that earn you the most?


An acceptable solution is a workable solution that accounts for all the different scenarios in a variable list of games with their completion times and payout rates.


Notes:


版权所有:编程辅导网 2018 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。