We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Data Structures
- Arrays
- Dynamic Array
- Discussions
Dynamic Array
Dynamic Array
Sort by
recency
|
1985 Discussions
|
Please Login in order to post a comment
C#
Can't say I enjoyed that one. Problem explanation was poor.
cpp solution:
def dynamicArray(n, queries): # Initialize the array of n empty lists arr = [[] for _ in range(n)] # Initialize lastAnswer to 0 lastAnswer = 0 # List to store the results of type 2 queries result = []
Read the input values
first_line = input().strip().split() n = int(first_line[0]) q = int(first_line[1]) queries = [input().strip() for _ in range(q)]
Call the function and get the result
output = dynamicArray(n, queries)
Print the results of type 2 queries
for res in output: print(res)