Implement SQL like query tool where from STDIN following things have to be read in the given order:-
1. Number of rows of the table (n) and Number of queries (q).
2. Table fields separated by Comma.
3. n line containing table rows of the table
4. q queries where clause.
We have to print output for each query on STDOUT.
Eg:-
Input:
4,2
"Name","Age","Sex","Salary"
1,"Joy",21,"M",2000
2,"Alan",28,"M",500
3,"John",30,"M",1000
4,"Nemo",45,"F",1500
Salary>=1000
Sex="M" and Salary>499
Output:
2
3
Can you guys tell how should I approach the problem? And What data structure should I be using to store the table and process the queries ?
PS: I am not asking for the ready made solution, I just need step wise help in solving this question.