Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
How to solve the Place Students problem shown below?

Question: Place Students

Problem Statement: There are N consecutive seats in the classroom. Each seat is either defective or not

In the classroom, there are X boys and Y girls students present. And you want to place them in such a way that there are no two consecutive (adjacent) seats where two boys or two girls are sitting Your task is to find the maximum number of students you can place Note: You can't place a student where the seat is defective.

Constraints:

1<=T<=10
1 <=N<= 10^5
0<=X, Y<=10^5

Input Format:
-> The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows

-> The first line of each test case contains three space-separated integers N, X, and Y.

-> The second line contains a string with length N, consisting of characters *.” and “#”. The dot means that the corresponding place is not defective. The hash (“#”) means that the corresponding place is defective

Output Format:
-> For each test case, print the maximum number of students you can place

Sample Input
7 1 4
.#....#
11 3 10
.#....#.#..
2 1 4

Sample Output
4 8 0

Explanation of Sample:-
Sample case 1: you can put 1 boy and 3 girls in the following way: “GHGBG#”
Sample case 2: you can put 3 boys and 5 girls in the following way: “G#GBGB#G#BG"

Here B means boy student, G means girl student.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!