Algorithmic Problem
You are given the arrival and leaving times of n customers in a restaurant.
What was the maximum number of customers?
Input
The first input line has an integer n: the number of customers.
After this, there are n lines that describe the customers. Each line has two integers a and b: the arrival and leaving times of a customer.
You may assume that all arrival and leaving times are distinct.
Output
Print one integer: the maximum number of customers.
Example
Input:
3
5 8
2 4
3 9
Output:
2
Write a program to create a class to store details of a student ( name, roll and 3 subject marks ). Input details for 2 students and assign all the details of that student who is having higher average mark to a new student.
i) use member function
ii) use friend function
Write a program to create a class to store details of a student ( name, roll and 3 subject marks ). Input details for 2 students and assign all the details of that student who is having higher average mark to a new student.
i) use member function
ii) use friend function
For each of the following, write a single statement that performs the single task. Define two integer
variables val1 and val2. Initialize the val1 to 2300.
1. Define a pointer myPointer to an object of type integer.
2. Assign the address of variable val1 to pointer.
3. Print the value of the object pointed to by myPointer.
4. Assign the value of the object pointed to by myPointer to variable val2.
5. Print the value of val2.
6. Print the address of val1.
7. Print the address stored in myPointer
Harry loves numbers in the range [m1, m2] (m1 and m2 included). carry decides to gift harry an array of numbers for his birthday. harry wants to find the number of pairs of indices [l, r] for which the sum of all the elements in the range [l, r] lies between m1 and m2.
Come up with an algorithm with a worst case complexity of O(N2).
Now improvise this algorithm, assuming all numbers are positive integers.
What if the numbers could be negative as well? Can you think of an O(nlogn) solution in this case? (Hint: use sorting)