FastPrepServer Finder with One Mismatch
Problems/Server Finder with One Mismatch

Server Finder with One Mismatch

Bloomberg LP logoBloomberg LP● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A senior software engineer's report from a Bloomberg on-site day describes a server-name lookup: a class built from a list of server names that gives back a server's index even when the typed name has one wrong letter, and treats a name with more wrong letters as not found. The round only asked the candidate to talk through approaches, so the report gives no code, limits or complete rules.

Everything else here is our practice choice. We use one function that answers a batch of queries instead of a class. Names use lowercase letters, and the server names are all different. A query matches a server when it has the same length and differs in at most one place; letters are never added or removed, and an exact copy counts as a match. When several servers match, the smallest index wins. A query with no match gives -1. There are 1 to 1000 servers and 1 to 1000 queries, and every name has 1 to 20 letters.

The judged task matches the report at about 75%.

A monitoring tool keeps a list of server names, servers. Operators type names into a search box, and the tool should still find the right server when one letter is wrong. You are given servers and a list of typed names, queries.

A query matches a server when both names have the same length and differ in at most one position. A name that is exactly the same also matches. Letters are never added or removed.

For each query, return the index of the server it matches. If several servers match, return the smallest index. If no server matches, return -1.

Return the answers in the order of queries.

Function

findServers(servers: String[], queries: String[]) → int[]

Examples

Example 1

servers = ["delta","omega"]queries = ["delta","delte","omexa","dexte","omegas"]return = [0,0,1,-1,-1]

Compare each query with each server name.

  • delta is the same as server 0, so the answer is 0.
  • delte differs from delta in one place (the last letter), so the answer is 0.
  • omexa differs from omega in one place (the fourth letter), so the answer is 1.
  • dexte differs from delta in two places (third and last letters) and is far from omega, so the answer is -1.
  • omegas has six letters and no server does, so the answer is -1.

Example 2

servers = ["cat","bat","rat"]queries = ["hat","cot","bat"]return = [0,0,0]

hat is one letter away from all three servers, so the smallest index, 0, is the answer. cot is one letter away from cat only, so the answer is 0.

bat is the same as server 1, but it is also one letter away from cat at index 0. The smallest matching index wins, so the answer is 0, not 1.

Example 3

servers = ["x"]queries = ["y","xy","x"]return = [0,-1,0]

A one-letter query is always within one letter of the one-letter server, so y and x give 0. xy has a different length, so it gives -1.

Example 4

servers = ["abcd","abdd","zzzz"]queries = ["abxd","zbzz","qqzz","abcd"]return = [0,2,-1,0]

abxd is one letter away from abcd (index 0) and from abdd (index 1), so the answer is 0. zbzz is one letter away from zzzz only, so the answer is 2. qqzz is two letters away from zzzz, so the answer is -1. abcd matches index 0 exactly, and index 1 also matches, so the smallest, 0, is the answer.

Constraints

  • 1 <= servers.length <= 1000
  • 1 <= queries.length <= 1000
  • 1 <= servers[i].length <= 20
  • 1 <= queries[j].length <= 20
  • Every name contains only lowercase English letters.
  • All names in servers are different.

More Bloomberg LP Onsite Interview questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Shortest Uncommon SubstringAirbnb · ONSITE INTERVIEWAirbnb interview questions
  • Feature Flags with Rules, Dependencies and ExposurePerplexity AI · ONSITE INTERVIEWPerplexity AI interview questions
  • Longest Substring Without Repeating CharactersOracle · ONSITE INTERVIEWOracle interview questions
  • Route Pattern MatcherGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Longest Substring Without Repeating CharactersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Classify Password StrengthHackerRank · PHONE SCREEN · ONSITE INTERVIEWHackerRank interview questions
  • Longest Substring Without Repeating CharactersMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Invoice / Payment ReconciliationStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • In-Memory Vault File SystemHarvey · ONSITE INTERVIEWHarvey interview questions
  • Longest Consecutive Login StreakAmazon · ONSITE INTERVIEW

Interview reports that mention this question

  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int[] findServers(String[] servers, String[] queries) {
        // Write your code here.
    }
}
Checking account…