3036. Number of Subarrays That Match a Pattern II
You are given a 0-indexed integer array
numsof sizen, and a 0-indexed integer arraypatternof sizemconsisting of integers-1,0, and1.A subarray
nums[i..j]of sizem + 1is said to match thepatternif the following conditions hold for each elementpattern[k]:
nums[i + k + 1] > nums[i + k]ifpattern[k] == 1.nums[i + k + 1] == nums[i + k]ifpattern[k] == 0.nums[i + k + 1] < nums[i + k]ifpattern[k] == -1.Return the count of subarrays in
numsthat match thepattern.
3035. Maximum Palindromes After Operations
You are given a 0-indexed string array
wordshaving lengthnand containing 0-indexed strings.You are allowed to perform the following operation any number of times (including zero):
- Choose integers
i,j,x, andysuch that0 <= i, j < n,0 <= x < words[i].length,0 <= y < words[j].length, and swap the characterswords[i][x]andwords[j][y].Return an integer denoting the maximum number of palindromes
wordscan contain, after performing some operations.Note:
iandjmay be equal during an operation.
3034. Number of Subarrays That Match a Pattern I
You are given a 0-indexed integer array
numsof sizen, and a 0-indexed integer arraypatternof sizemconsisting of integers-1,0, and1.A subarray
nums[i..j]of sizem + 1is said to match thepatternif the following conditions hold for each elementpattern[k]:
nums[i + k + 1] > nums[i + k]ifpattern[k] == 1.nums[i + k + 1] == nums[i + k]ifpattern[k] == 0.nums[i + k + 1] < nums[i + k]ifpattern[k] == -1.Return the count of subarrays in
numsthat match thepattern.
Given a 0-indexed
m x ninteger matrixmatrix, create a new 0-indexed matrix calledanswer. Makeanswerequal tomatrix, then replace each element with the value-1with the maximum element in its respective column.Return the matrix
answer.