Solve three algorithmic OA tasks
DRWSoftware Engineer · Online AssessmentLast updated
Solve three algorithmic OA tasks evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Task 1 (Odd-frequency string): Given an integer N in [1..200000], write an algorithm that returns any length-N string of lowercase letters (a–z) such that every letter that appears occurs an odd number of times.
Task 2 (Min-difference with minimal swaps): Given two equal-length digit strings S and T (length N up to 100000, digits only, no leading zeros), you may choose a subset of indices and swap S[i] with T[i] at each chosen index. Among all swap choices that minimize |int(S) − int(T)|, return the minimum number of swaps required. For example, S = "29162" and T = "10524" should return 2.
Task 3 (Two-choice slot assignment): Given arrays A and B of length N (1 ≤ A[k], B[k] ≤ S, A[k] ≠ B[k]) and an integer S (2. 100000), determine whether it is possible to assign every patient k to either A[k] or B[k] so that at most one patient is assigned to each slot. Return true if such an assignment exists, otherwise false.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.