This repository contains a TypeScript solution to a common coding interview question focusing on string manipulation and analysis. The problem and its solution are designed to demonstrate proficiency in algorithms, data structures, and TypeScript.
Given an array of strings, write a function to find and return an array of characters that appear in the same position across all strings. The function should ignore case and special characters, providing a case-sensitive match for common characters. If a character appears more than once in all strings at the same position, it should be included in the output array multiple times.
-
Input:
["abcd", "bcd", "cde", "cdef"]
-
Output:
["c", "d"]
-
Input:
["nillie", "illie", "bllie"]
-
Output:
["i", "l", "l", "e"]
The solution to this problem can be found in the index.ts file. The core algorithm iterates over the characters of the first string and checks for their presence in the same position across the other strings, adjusting for characters that have already been matched.
- String Manipulation: Efficiently handling strings and character comparisons.
- Algorithm Complexity: Optimizing for both time and space complexity.
- TypeScript Features: Utilizing TypeScript for type safety and clarity.
To ensure the correctness of the solution, a comprehensive suite of tests has been provided. These tests cover various scenarios, including edge cases, to validate the functionality of the implemented algorithm.
To run the tests, follow these steps:
# Install dependencies
bun install
# Run the tests
bun test
While this repository is primarily for a coding interview solution, contributions for improvements or alternative solutions are welcome. Please feel free to fork the repository, make your changes, and submit a pull request.
This coding challenge solution is aimed at developers looking for examples of coding interview questions and solutions, specifically those involving TypeScript and string manipulation algorithms.