Solve Three OA Coding Tasks
Company: Prodigy
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Take-home Project
This online assessment included the following coding problems:
1. **Reverse the middle of vowel-bounded words**
You are given an array of lowercase strings. For each string, if its first and last characters are both vowels (`a`, `e`, `i`, `o`, `u`), reverse only the substring between them and keep the first and last characters fixed. Otherwise, leave the string unchanged. Return the transformed array.
2. **Place fixed shapes on a grid**
You are given an empty `m x n` board and four shape masks represented as binary matrices, where `1` means the shape occupies that cell and `0` means empty space inside the shape's bounding box. One example shape is `[[0,1,0],[1,1,1]]`. Each shape must be placed exactly once in its given orientation only; rotations and reflections are not allowed. Shapes may not overlap, and each board cell can belong to at most one shape. For each shape, choose the valid placement with the smallest row index; if there is a tie, choose the one with the smallest column index. Return the final board filled with shape IDs `1..4`, or report that placement is impossible.
3. **Count odd-even-odd alternating subarrays**
You are given an integer array that may contain negative numbers. Count the number of contiguous subarrays whose first element is odd and whose parity alternates on every step, i.e. `odd, even, odd, even, ...`. For negative numbers, determine odd/even by absolute value, so `-3` is odd and `-4` is even. Return the total count of such subarrays.
Quick Answer: This set of problems evaluates string and array manipulation, spatial placement and packing logic, and parity-based subarray counting within the Coding & Algorithms domain, requiring algorithmic problem-solving, data-structure use, and precise implementation.