Category : logic

There is a question that states. Given an array obtain the 3rd highest element. Now suppose this is the array (lets assume that its sorted for now for simplicity – otherwise it can be unsorted) //{1,2,3,4} –>Array under question. The answer is 2. solution: int findnHighest(std::vector<int> v, int n=3) { std::priority_queue<int, std::vector<int>, std::greater<int>> pq(v.begin(), v.begin() ..

Read more