REST API: Country Codes
Updated
Problem statement
You are given a country name country, a phone-number string phoneNumber, and countryRecords, an offline representation of the country API data. Each row contains a country name followed by that record's calling codes in API order.
Find the row whose country name exactly equals country. If no row matches, return -1. Otherwise, use the row's last calling code and return +<calling code> <phone number>. Preserve phoneNumber exactly, including leading zeroes.
Function
getPhoneNumbers(country: String, phoneNumber: String, countryRecords: String[][]) → StringExamples
Example 1
country = "Afghanistan"phoneNumber = "6564454455"countryRecords = [["Afghanistan","93"]]return = "+93 6564454455"The supplied Afghanistan record has one calling code, 93, so the formatted result is +93 6564454455.
Example 2
country = "Puerto Rico"phoneNumber = "564539386"countryRecords = [["Puerto Rico","1787","1939"]]return = "+1939 564539386"The Puerto Rico record has calling codes [1787, 1939]. The last entry is 1939, so that code is used.
Example 3
country = "Oceania"phoneNumber = "987574876"countryRecords = [["Afghanistan","93"],["Puerto Rico","1787","1939"]]return = "-1"No supplied record has the exact country name Oceania, so the function returns -1.
Constraints
0 <= countryRecords.length <= 3002 <= countryRecords[i].length <= 10- Country names in
countryRecordsare unique. - Country names contain English letters and spaces.
- Calling codes and
phoneNumbercontain decimal digits.
More Palantir interview questions
- Query Words Within K PositionsPHONE SCREEN · Seen Nov 2026
- Basic Item DiscountsOA · Seen Nov 2026
- Optimize Discount Selection Under a Point BudgetOA · Seen Nov 2026
- Stacked Item and Category DiscountsOA · Seen Nov 2026
- Balanced Session ManagerPHONE SCREEN · Seen Oct 2026
- Map and Accumulate Learning QueriesONSITE INTERVIEW · Seen Oct 2026
- Employees With Shared InterestsPHONE SCREEN · Seen Jul 2025
- Relational Learning QueriesONSITE INTERVIEW · Seen Apr 2025
- Find Unmet Users With Shared InterestsONSITE INTERVIEW · Seen Mar 2025
- Merge a 2048 RowPHONE SCREEN · Seen Jan 2025
Similar questions at other companies
- Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
- Branch with the Most FilesCapital One · OACapital One interview questions
- REST API: Highest International StudentsRippling · OARippling interview questions
- Rearrange String by Alternating EndsHudson River Trading · OAHudson River Trading interview questions
- Filter Isolated Interior Signal BitsSEDEMAC · OA
- Scale Ingredient QuantitiesUpstart · OAUpstart interview questions
- Telephone Keypad String EncodingEpic · OAEpic interview questions
- Count Invalid Log GroupsIBM · OAIBM interview questions
- Count Case-Insensitive TripletsTikTok · OATikTok interview questions
- Simulate a Deterministic Finite AutomatonPoint72 · OAPoint72 interview questions
Palantir interview experiences
- Palantir FDSE Experienced-Hire Interviews: 5 Experiences
- Palantir FDSE New Grad OA Questions: 6 Experiences (Part 2 of 2)
- Palantir FDSE New Grad Interviews: 5 Experiences (Part 1 of 2)
- Palantir FDSE Intern OA and Interviews: 3 Experiences
- Palantir FDSE Karat and Learning: 7 Experiences (Part 2 of 2)
- Palantir FDSE OA and Interviews: 16 Experiences (Part 1 of 2)