Google Online Assessment (OA) 2021 | Create String
You are given an integer n
and a list of integers with size m
, and you are asked to
produce a string with length n
with the following requirements: For 0 <= i < n
,
if i
is in the list, then the character at position i
is a plus sign (+
). Otherwise,
it is a minus sign (-
).
Parameter
n
: An integer representing the size of the string.int_list
: A list of integers.
Result
- The desired string according to the specifications.
Examples
Example 1:
Input: n = 5
, int_list = [2, 4]
Output: "--+-+"
Constraints
1 <= n <= 10^5
0 <= m <= 10^5