Skip to content

Commit 9cf62f9

Browse files
authored
Create Readme.md
1 parent 214077d commit 9cf62f9

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Policemen catch thieves
2+
3+
Given an array of size n that has the following specifications:
4+
5+
Each element in the array contains either a policeman or a thief.
6+
Each policeman can catch only one thief.
7+
A policeman cannot catch a thief who is more than K units away from the policeman.
8+
We need to find the maximum number of thieves that can be caught.
9+
Examples:
10+
11+
```bash
12+
Input : arr[] = {'P', 'T', 'T', 'P', 'T'},
13+
k = 1.
14+
Output : 2.
15+
```
16+
Here maximum 2 thieves can be caught, first
17+
policeman catches first thief and second police-
18+
man can catch either second or third thief.
19+
20+
```
21+
Input : arr[] = {'T', 'T', 'P', 'P', 'T', 'P'},
22+
k = 2.
23+
Output : 3.
24+
```
25+
```
26+
Input : arr[] = {'P', 'T', 'P', 'T', 'T', 'P'},
27+
k = 3.
28+
Output : 3.
29+
```

0 commit comments

Comments
 (0)