Knowee
Questions
Features
Study Tools

Constraints:Input:First line contains T number of test cases. First line of each test case contains N, the number of friends Christie currently has and K ,the number of friends Christie decides to delete. Next lines contains popularity of her friends separated by space.Output:For each test case print N-K numbers which represent popularity of Christie friend's after deleting K friends.

Question

Constraints:Input:First line contains T number of test cases. First line of each test case contains N, the number of friends Christie currently has and K ,the number of friends Christie decides to delete. Next lines contains popularity of her friends separated by space.Output:For each test case print N-K numbers which represent popularity of Christie friend's after deleting K friends.

🧐 Not the exact question you are looking for?Go ask a question

Solution

This problem is about deleting the least popular friends from Christie's friend list. Here's a step-by-step guide on how to solve it:

  1. Read the number of test cases, T, from the input.

  2. For each test case, do the following:

    a. Read the number of friends, N, and the number of friends to delete, K.

    b. Read the popularity of each friend into a list.

  3. To delete the K least popular friends, sort the list of popularity in descending order. This way, the most popular friends will be at the beginning of the list and the least popular friends will be at the end.

  4. Remove the last K elements from the sorted list. These are the K least popular friends.

  5. Print the remaining elements in the list. These are the popularity of Christie's friends after deleting the K least popular ones.

  6. Repeat steps 2-5 for each test case.

This algorithm assumes that the popularity of each friend is unique. If two or more friends have the same popularity, the algorithm may delete more friends than necessary. To handle this case, you can use a priority queue or a similar data structure that allows you to delete the least popular friends one by one, checking their popularity each time.

This problem has been solved

Similar Questions

Understand the problem statement from the given sample input and output.Input FormatThe first line of input contains T - the number of test cases. It's followed by T lines, each line contains 2 strings A and B, separated by space, consisting only of lowercase English alphabets.Output FormatFor each test case, print the desired output, separated by a new line.Constraints10 points1 <= T <= 1001 <= len(A), len(B) <= 10040 points1 <= T <= 10001 <= len(A) <= 50001 <= len(A), len(B) <= 5000ExampleInput2data structuressmart interviewsOutputsrucuresineview

Input FormatThe first line of input contains T - the number of test cases. It's followed by T lines, each line contains 2 numbers N and P, separated by space.Output FormatFor each test case, print the value of N % P, separated by a new line.Constraints20 points1 <= T <= 1001 <= N <= 10181 <= P <= 10880 points1 <= T <= 1001 <= N <= 10100001 <= P <= 1015ExampleInput45 24 101085377843 817659438290826691135830692772803 95972011Output142242058460316167

Given an array of size 3X+1, where every element occurs three times, except one element, which occurs only once. Find the element that occurs only once.Input FormatThe first line of input contains T - the number of test cases. It's followed by 2T lines, the first line contains N - the size of the array (of the form 3X + 1) and second line contains the elements of the array.Output FormatFor each test case, print the number which occurs only once, separated by new line.Constraints30 points1 <= T <= 1001 <= N <= 10370 points1 <= T <= 1001 <= N <= 106ExampleInput2105 7 8 7 7 9 5 9 5 9710 20 20 30 20 30 30Output810

There are N cows living in a cowshed, they all are standing in a line numbered form 1 to N in ascending order. The farmer is in funny mood so he made his mind to do something different, he decides to clean K cows from front and K cows from last and so on. A cow whose name is bessy trying to figure out last turn to get clean will belong to which number of cow, she needs your help to find this.Input Format :Input contains two lines , first line of input contains t - Number of test cases.Next t lines will contains two integers N and K - Number of cows and number of cows farmer is selecting from front and end.Output Format :Print the position of cow for every test case in a new line who will get the last turn.Example:Input:29 325 7Output:615Constraints:1. 1 <= T <= 102. 1 <= K<= N <= 10^5

Given an array of integers and a window size K, find the number of distinct elements in every window of size K of the given array.Input FormatThe first line of input contains T - the number of test cases. It's followed by 2T lines. The first line of each test case contains the N-size of the array and the K-size of the window. The second line contains N integers - elements of the array.Output FormatFor each test case, print the number of distinct elements in every window of size K, separated by a new line.Constraints30 points1 <= N <= 1001 <= K <= N70 points1 <= N <= 100001 <= K <= NGeneral Constraints1 <= T <= 1000-100 <= ar[i] <= 100ExampleInput35 3-2 -4 -2 4 -210 73 -4 -3 -4 -2 0 2 -2 6 017 13-5 -1 4 8 -5 -3 -4 7 4 -4 0 8 0 -2 3 2 5Output2 3 26 5 6 58 9 9 10 11

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.