TestDome scores range 0–100% .
Most companies set a passing threshold at 75% . If you score below, they often do not proceed to the next interview round.
Question:
Write a function that merges two strings alternately, starting with the first string. If one string is longer, append the remaining characters.
Example:
"abc", "123" → "a1b2c3"
"ab", "1234" → "a1b234" testdome java questions and answers
Solution:
public class StringMerge
public static String merge(String s1, String s2) i < s2.length())
if (i < s1.length()) result.append(s1.charAt(i));
if (i < s2.length()) result.append(s2.charAt(i));
i++;
return result.toString();
Why it works:
Before your actual exam, write code for these variations: TestDome scores range 0–100%
A. Palindrome with Mixed Cases
// Returns true if string is palindrome, ignoring case and non-alphanumeric
public static boolean isPalindrome(String s)
// Write solution using two pointers
B. User Roles (Enum + Set)
// Given a list of permissions (READ, WRITE, DELETE), return true if user can perform action
enum Permission READ, WRITE, DELETE
class User
Set<Permission> permissions;
public boolean can(Permission p) ...
C. Cache with LRU (Hard)
// Implement an LRU cache with get(key) and put(key, value) methods
// Use LinkedHashMap with accessOrder=true
import java.util.ArrayDeque; import java.util.Deque;public class TrainComposition private Deque<Integer> deque = new ArrayDeque<>();
public void attachWagonFromLeft(int wagonId) deque.addFirst(wagonId); public void attachWagonFromRight(int wagonId) deque.addLast(wagonId); public int detachWagonFromLeft() if (deque.isEmpty()) return -1; // Required by grader return deque.removeFirst(); public int detachWagonFromRight() if (deque.isEmpty()) return -1; return deque.removeLast();
Key insight: ArrayDeque offers O(1) insertion/removal at both ends. LinkedList would also work but uses more memory. Returning -1 on empty deque is specific to TestDome's hidden expectations.