Find School Count
Given the dataset of schools and the subjects they offer as a pandas dataframe, perform the following operations:
- Drop all the schools offering fewer than 3 subjects.
- Clean the
state_code
column such that it only contains alpha-numeric characters. - For each state, return the number of schools offering English, Maths, Physics and Chemistry, each in a separate column.
The given dataframe consists of three columns:
school_id
- School ID for each studentstate_code
- Unique identifier for each statesubjects
- space-separated strings of subjects, all in lowercase
Consider the following dataframe:
school_id | state_code | subjects |
---|---|---|
sch_1 | l@sc_1 | english maths chemistry |
sch_2 | )}sc_2 | english physics chemistry |
sch_3 | l@sc_2 | maths biology |
sch_4 | sc_2 | _ |
sch_5 | sc_1#@ | social_studies maths literature |
sch_6 | sc_10#@ | english maths history |
Function Description
Complete the function schoolCount
in the editor below.
schoolCount
has the following parameter(s):
df
: a pandas dataframe
Returns
pandas dataframe
: the results of processing maintaining the original order that state codes are encountered
Constraints
1 ≤ number of rows in df ≤ 1000

Analyzing Arrays
Consider a 1-based array of n integers, arr[n]
. For each element arr[i]
where 1 ≤ i ≤ n
, determine the value of arr[i]^(arr[i+1]) modulo (10^9 + 7)
. Return the lowest index of the highest modulo value.
Example
arr = [3, 5, 4, 5, 2, 10]
index i | arr[i]^(arr[i+1]) modulo (10^9 + 7) | result |
---|---|---|
1 | 3^5 modulo (10^9 + 7) | 243 |
2 | 5^4 modulo (10^9 + 7) | 625 |
3 | 4^5 modulo (10^9 + 7) | 1024 |
4 | 5^2 modulo (10^9 + 7) | 25 |
5 | 2^10 modulo (10^9 + 7) | 1024 |
The greatest of these values is 1024
occurring at indices 3
and 5
. Return the smaller index, 3
.
Function Description
Complete the function powerArray
in the editor.
powerArray
has the following parameter:
int arr[n]
: the integers to analyze
Returns:
int
: the smallest index element that results in the highest value
Constraints
1 ≤ n ≤ 10^5
1 ≤ arr[i] ≤ 100

Parameters:
string s1
: the first string, which always has a length of3
string s2
: the second string
Returns:
int
: the number of timess1
appears as a subsequence ins2
Constraints:
length of s1 = 3
1 ≤ length of s2 ≤ 5 * 10^5
s1
ands2
consist of uppercase English letters,A-Z
