Write an algorithm that can determine a list of matching officer hours with a string. Your algorithm needs to be as efficient as possible and you need to prove its running time in the worst case.

For this problem, you only care about the faculty name, course department, course number of an office hour.

Faculty name is a string. e.g.: ‘Joe Doe’, ‘Winkelman’. (case-insensitive)

Course department is a string. e.g.: ‘CS’, ‘Computer Science’. (case-insensitive)

Course number is an integer. e.g.: 220, 520.

Searching field

Course department and Course number is combined like so:

‘CS 100’.

Faculty name and course are split by a comma:

‘Jeremi Minea, PSY 100’ or ‘PSY 100, Jeremi Minea’.

If give input does not match this format:

return [ ];

Data structure

For example, if this were the Office Hour class:

export class OfficeHour {
  constructor(facultyName,
              courseDepartment,
              courseNumber) {
    this.facultyName = facultyName;
    // eg. CS, Bio, Chem
    this.courseDepartment = courseDepartment;
    // eg. 520, 320, 326
    this.courseNumber= courseNumber;
  }
}

You can have:

new OfficeHour(
      'John Doe',
      'CS',
      520,
),

Test cases

Given test data:

const database = [
	new OfficeHour(
      'John Doe',
      'CS',
      520,
  ),
  new OfficeHour(
      'Cuphead',
      'Bio',
      110,
  ),
  new OfficeHour(
      'Chengtao',
      'CS',
      777,
  ),
  new OfficeHour(
      'Leo',
      'Math',
      411,
  ),
];

function:

const retrieveOHList(inputText, db) {}

case 1: