0% found this document useful (0 votes)
2K views3 pages

SIG Interview Questions

The coding question

Uploaded by

sureshrmdec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views3 pages

SIG Interview Questions

The coding question

Uploaded by

sureshrmdec
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

From the onsite interview in the second session with the Leads: How would you handle processing

multiple
millions of trade requests if the number of servers wasn't a question? The one manager kept on following
up my answers with, "Well what if that wasn't available?"
1 Answer
Ultimately, I think they were looking for: "I would use a queue." Although I'm not really sure. I was trying
to figure out what the one manager was getting at, but there was a question of clarity in the questions he
was asking that was absent. By no means was this a perfect interview --on either side.

Coding Question A group of friends are tracking the miles per gallon for each of their cars. Each time one
of them fills up their gas tank, they record the following in a file:
His or her name
The type of car they drove
How many miles driven since they last filled up
How many gallons purchased at this fill up
Date of the fill
Their data is formatted as a comma separate value (csv) file with the following format for each
row:(#person,carName,milesDriven,gallonsFilled,fillupDate)

Miles are recorded as floating-point numbers and gallons as integers.

Please create a program that allows


members of this group to determine the miles per gallon (MPG)
of each of their cars during a specific time range.

Note: person may have more than one so a time range query
might need to output data for one or more cars.
A skeleton class will be provided;
your job will be to complete the program.
The principal function for querying MPG is of the form
(the exact name, data types, etc., can be learned by inspecting the "solution" class in the skeleton code):

GetRangeMPG(PersonName, StartDate, EndDate)

Returns list of objects containing (CarName, MPG)

MPG is calculated as (total miles traveled during time period)/ (total gallons filled during time period.

The dates you receive in the query should be treated inclusively.


create a 366 vector each item corresponds to the date.

Given as list of movies in a csv file,


extract the movie name and genre
and be able to return a query based on the years.

#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
unordered_map<int, unordered_map<string, vector<string>>> m;
class movie {
public:
string name;
string genre;
int year;
movie (string n, string g, int y):name(n), genre(g), year(y){}
};

void loadmovies(vector<movie *>ml) {


for (auto i:ml)
m[i->year][i->genre].push_back(i->name);
}

void printmoviebyyear(int year){


if (!m.count(year)) cout << "No movies found" <<endl;
for (auto i:m[year]){
cout << i.first << endl;
for (auto j:i.second)
cout << j << endl;
}
}
int main() {
// your code goes here
vector<movie *>ml;
ml.push_back(new movie ("Amarkalam", "Action", 2001));
ml.push_back(new movie ("Vaali", "Drama", 1998));
ml.push_back(new movie ("Dheena", "Action", 2003));
ml.push_back(new movie ("Citizen", "Horror", 2004));
ml.push_back(new movie ("Badri", "Action", 2001));
ml.push_back(new movie ("Kushi", "Drama", 1998));
ml.push_back(new movie ("Red", "Action", 2003));
ml.push_back(new movie ("TMT", "Love", 2004));
loadmovies(ml);
printmoviebyyear(2004);
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy