πŸ’‘ Share CareerRaah β€” it's 100% free! πŸš€

Back to BlogSDET Technical Prep

Top 30 Playwright TypeScript Programs

Most Asked Coding Challenges in SDET Technical Interviews

VD
Vishvas Dhengula
June 9, 2026
15 min read

Want to Practice on a Live Sandbox?

Over 1,000+ SDETs practice daily inside our built-in browser compiler to test algorithms and crack top automation engineering interviews.

Open Built-in Code Sandbox

SDET Coding Challenge Directory

Coding tests are a standard filter in any Senior SDET or Test Architect interview. Below is the curated compilation of the Top 30 Coding Challenges asked in modern Playwright / TypeScript automation technical interviews.

1.Reverse a String

TS

Reverses a string by iterating backwards from the last character and appending each character to a result string.

Time: O(N) | Space: O(N)Concept: String Manipulation, Iteration
function reverse(s: string) {
  let res = '';
  for(let i = s.length-1; i >= 0; i--)
    res += s[i];
  return res;
}

2.Check Palindrome

TS

Checks if a string reads the same forwards and backwards using a two-pointer approach comparing characters from outer ends inward.

Time: O(N) | Space: O(1)Concept: Two-Pointer Technique
function isPalindrome(s: string) {
  let l = 0, r = s.length-1;
  while(l < r) {
    if(s[l++] !== s[r--]) return false;
  }
  return true;
}

3.First Unique Character

TS

Finds the first character in a string that does not repeat. Uses a frequency map to count occurrences, then scans the string to find the first character with a count of 1.

Time: O(N) | Space: O(U) where U is unique charactersConcept: Hash Map, Frequency Counting
function firstUniq(s: string) {
  const map: Record<string,number> = {};
  for(const c of s) map[c] = (map[c]||0)+1;
  
  for(const c of s) {
    if(map[c] === 1) return c;
  }
  return null;
}

4.Character Frequency

TS

Counts the occurrence of each character in a string and returns a dictionary/object mapping characters to their counts.

Time: O(N) | Space: O(U)Concept: Object Mapping, Frequency Counting
function charFreq(s: string) {
  const map: Record<string,number> = {};
  for(const c of s) {
    map[c] = (map[c]||0)+1;
  }
  return map;
}

5.Remove Array Duplicates

TS

Removes duplicate values from an array using JavaScript’s Set collection, which automatically filters out duplicate elements.

Time: O(N) | Space: O(N)Concept: ES6 Set, Array Conversion
function removeDups(arr: number[]) {
  return Array.from(new Set(arr));
}

6.Check Anagram

TS

Determines if two strings are anagrams by sorting their characters and comparing the resulting strings for equality.

Time: O(N log N) | Space: O(N)Concept: String Sorting, Normalization
function isAnagram(s1: string, s2: string) {
  if(s1.length !== s2.length) return false;
  const norm = (s: string) => 
    s.split('').sort().join('');
  return norm(s1) === norm(s2);
}

7.Bubble Sort

TS

A simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.

Time: O(NΒ²) | Space: O(1)Concept: Sorting Algorithms, In-place Swap
function bubbleSort(arr: number[]) {
  for(let i=0; i<arr.length-1; i++) {
    for(let j=0; j<arr.length-i-1; j++) {
      if(arr[j] > arr[j+1]) {
        [arr[j], arr[j+1]] = [arr[j+1], arr[j]];
      }
    }
  }
  return arr;
}

8.Selection Sort

TS

Sorts an array by repeatedly finding the minimum element from the unsorted part and putting it at the beginning.

Time: O(NΒ²) | Space: O(1)Concept: Sorting Algorithms, Min-finding
function selectSort(arr: number[]) {
  for(let i=0; i<arr.length-1; i++) {
    let min = i;
    for(let j=i+1; j<arr.length; j++)
      if(arr[j] < arr[min]) min = j;
    [arr[i], arr[min]] = [arr[min], arr[i]];
  }
  return arr;
}

9.Second Largest Number

TS

Finds the second largest number in an array in a single pass by keeping track of the largest and second largest elements found so far.

Time: O(N) | Space: O(1)Concept: Single-pass Search, State Tracking
function secondLarge(a: number[]) {
  let max = -Infinity, sec = -Infinity;
  for(const n of a) {
    if(n > max) { sec=max; max=n; }
    else if(n > sec && n !== max) sec=n;
  }
  return sec;
}

10.Missing Number (1 to N)

TS

Finds the single missing number in an array containing numbers from 1 to N using the arithmetic sum formula: Sum = N * (N + 1) / 2.

Time: O(N) | Space: O(1)Concept: Math Formula, Sum Reduction
function missingNum(arr: number[], n: number) {
  const expSum = (n * (n + 1)) / 2;
  const actSum = arr.reduce((a,b)=>a+b,0);
  return expSum - actSum;
}

11.Reverse Words in Sentence

TS

Reverses the order of words in a sentence by splitting the string by whitespace, reversing the array of words, and joining them back.

Time: O(N) | Space: O(N)Concept: String Splitting, Array Reversal
function revWords(s: string) {
  return s.trim().split(/\s+/).reverse().join(' ');
}

12.Roman to Integer

TS

Converts a Roman numeral string into its integer equivalent by scanning the string and subtracting values when a smaller numeral precedes a larger one.

Time: O(N) | Space: O(1)Concept: Roman Numeral Rules, Iteration
function romanToInt(s: string) {
  const map: any = { I:1, V:5, X:10, L:50 };
  let tot = 0;
  for(let i=0; i<s.length; i++) {
    if(map[s[i]] < map[s[i+1]]) tot -= map[s[i]];
    else tot += map[s[i]];
  }
  return tot;
}

13.Merge Sorted Arrays

TS

Merges two already sorted arrays into a single sorted array using a two-pointer technique for optimal linear time complexity.

Time: O(N + M) | Space: O(N + M)Concept: Two-Pointer, Array Merging
function mergeArr(a: number[], b: number[]) {
  let res = [], i=0, j=0;
  while(i < a.length && j < b.length)
    res.push(a[i] <= b[j] ? a[i++] : b[j++]);
  return [...res, ...a.slice(i), ...b.slice(j)];
}

14.Binary Search O(log N)

TS

Finds the index of a target value in a sorted array by repeatedly dividing the search interval in half.

Time: O(log N) | Space: O(1)Concept: Divide & Conquer, Sorted Arrays
function binSearch(a: number[], t: number) {
  let l = 0, r = a.length-1;
  while(l <= r) {
    let m = Math.floor((l+r)/2);
    if(a[m] === t) return m;
    a[m] < t ? l=m+1 : r=m-1;
  }
  return -1;
}

15.FizzBuzz

TS

Prints numbers from 1 to N, but prints "Fizz" for multiples of 3, "Buzz" for multiples of 5, and "FizzBuzz" for multiples of both.

Time: O(N) | Space: O(1)Concept: Modulo Operations, Conditionals
function fizzBuzz(n: number) {
  for(let i=1; i<=n; i++) {
    let out = '';
    if(i%3===0) out += 'Fizz';
    if(i%5===0) out += 'Buzz';
    console.log(out || i);
  }
}

16.Fibonacci (Memoized)

TS

Calculates the N-th Fibonacci number efficiently using recursion combined with memoization (caching intermediate results) to prevent exponential runtime.

Time: O(N) | Space: O(N)Concept: Recursion, Memoization, Dynamic Programming
const memo: Record<number,number> = {};
function fib(n: number): number {
  if(n <= 1) return n;
  if(memo[n]) return memo[n];
  return memo[n] = fib(n-1) + fib(n-2);
}

17.Factorial (Recursive)

TS

Computes the factorial of a number N using standard mathematical recursion.

Time: O(N) | Space: O(N)Concept: Recursion, Call Stack
function factorial(n: number): number {
  if (n === 0 || n === 1) return 1;
  return n * factorial(n - 1);
}

18.Two Sum O(N)

TS

Finds the indices of two numbers in an array that add up to a specific target value, using a Map to store indices of visited numbers for lookups.

Time: O(N) | Space: O(N)Concept: Hash Map Lookup, Complement Search
function twoSum(a: number[], t: number) {
  const map = new Map();
  for(let i=0; i<a.length; i++) {
    const comp = t - a[i];
    if(map.has(comp)) return [map.get(comp), i];
    map.set(a[i], i);
  }
  return [];
}

19.Max Subarray (Kadane)

TS

Finds the contiguous subarray within a one-dimensional array of numbers which has the largest sum using Kadane’s dynamic programming algorithm.

Time: O(N) | Space: O(1)Concept: Dynamic Programming, Kadane’s Algorithm
function maxSubArray(nums: number[]) {
  let curr = nums[0], max = nums[0];
  for(let i=1; i<nums.length; i++) {
    curr = Math.max(nums[i], curr + nums[i]);
    max = Math.max(max, curr);
  }
  return max;
}

20.Valid Parentheses

TS

Checks if a string of braces and brackets is valid by matching opening and closing characters using a stack data structure.

Time: O(N) | Space: O(N)Concept: Stack Data Structure, String Parsing
function isValid(s: string) {
  const stack = [], map: any = { ')':'(', '}':'{' };
  for(const c of s) {
    if(!map[c]) stack.push(c);
    else if(stack.pop() !== map[c]) return false;
  }
  return stack.length === 0;
}

21.Check Prime Number

TS

Determines if a number N is prime by checking divisibility up to the square root of N.

Time: O(√N) | Space: O(1)Concept: Mathematical Optimizations, Prime Checks
function isPrime(n: number) {
  if(n <= 1) return false;
  for(let i = 2; i <= Math.sqrt(n); i++)
    if(n % i === 0) return false;
  return true;
}

22.Count Vowels

TS

Counts the number of vowels (a, e, i, o, u) in a string using a predefined Set for efficient constant-time checks.

Time: O(N) | Space: O(1)Concept: Set Lookups, Character Iteration
function countVowels(s: string) {
  const vowels = new Set(['a','e','i','o','u']);
  let count = 0;
  for(const c of s.toLowerCase()) {
    if(vowels.has(c)) count++;
  }
  return count;
}

23.Array Intersection

TS

Finds the common elements between two arrays by converting one array into a Set and filtering the second array.

Time: O(N + M) | Space: O(N)Concept: Set Operations, Array Filtering
function intersection(a: number[], b: number[]) {
  const setA = new Set(a);
  return b.filter(x => setA.has(x));
}

24.Sum of Array Elements

TS

Computes the total sum of all elements in an array using JavaScript’s native Array.prototype.reduce helper.

Time: O(N) | Space: O(1)Concept: Array Reduction, Aggregation
function arraySum(arr: number[]) {
  return arr.reduce((acc, curr) => acc + curr, 0);
}

25.Find Maximum Element

TS

Finds the largest number in an array using Math.max combined with ES6 spread operator.

Time: O(N) | Space: O(1)Concept: Math operations, Spread Operator
function findMax(arr: number[]) {
  return Math.max(...arr);
}

26.Reverse Array In-Place

TS

Reverses the elements of an array in-place without allocating extra memory by swapping values from the outer boundaries moving inward.

Time: O(N) | Space: O(1)Concept: In-place Modification, Two-Pointer Swap
function reverseArray(arr: any[]) {
  let l = 0, r = arr.length - 1;
  while (l < r) {
    [arr[l], arr[r]] = [arr[r], arr[l]];
    l++; r--;
  }
  return arr;
}

27.Find All Duplicates

TS

Finds all elements that appear more than once in an array using sets to keep track of seen and duplicate values.

Time: O(N) | Space: O(N)Concept: Set Collections, Duplicate Filtering
function findDuplicates(arr: number[]) {
  const seen = new Set(), dups = new Set();
  for (const n of arr) {
    if(seen.has(n)) dups.add(n);
    seen.add(n);
  }
  return Array.from(dups);
}

28.Capitalize First Letters

TS

Capitalizes the first letter of each word in a string/sentence by splitting, mapping, and joining.

Time: O(N) | Space: O(N)Concept: String Parsing, Word Capitalization
function capitalize(s: string) {
  return s.split(' ')
          .map(w => w[0].toUpperCase() + w.slice(1))
          .join(' ');
}

29.Check Substring

TS

Validates if a specific substring exists inside a parent string using JavaScript’s native indexOf helper.

Time: O(N) | Space: O(1)Concept: Substring Checking, Native APIs
function containsSub(s: string, sub: string) {
  return s.indexOf(sub) !== -1;
}

30.Flatten Nested Array

TS

Flattens an array with arbitrary nested arrays into a single flat array using recursive reduction.

Time: O(N) | Space: O(N)Concept: Recursion, Array Concatenation
function flatten(arr: any[]): any[] {
  return arr.reduce((acc, val) => 
    Array.isArray(val) ? 
    acc.concat(flatten(val)) : acc.concat(val)
  , []);
}
πŸ€–

Have a specific question? Ask our AI Coach!

Explore custom roadmaps, ask technical questions, and design your QA and AI interview preparation path.

Ask AI Coach