The article https://habr.com/ru/articles/926214/ listed three interview test samples. I was curious to try them myself, since I haven't interviewed in a long time
The Benchmark project is designed to measure the algorithm's performance (execution speed) and memory usage.
The Tests project contains test cases to verify the correctness of the algorithm.
The Sandbox project contains the actual algorithm implementation.
Given two sorted integer arrays (ascending order), possibly of different lengths, merge them into a single sorted array without duplicates, using only constant extra memory.
Keyboard is broken:
- When he presses
b, it deletes the last lowercase letter entered. - When he presses
B, it deletes the last uppercase letter entered. All other keys work normally.
Given a string consisting of uppercase and lowercase English letters (representing the sequence of key presses), determine the final output.
Given an array of non-negative integers, find a contiguous subarray with the maximum sum where there are no more than two distinct numbers. Return the sum.
Example:
[10, 10, 5, 5] → Valid (only two distinct numbers: 10 and 5).