Scale AI VO 面试真题解析:使用 Google Maps API 获取地点 ID 的列表查询

17次阅读
没有评论

You are given a starting location and a list of resort names. In this interview, you should access the Maps APIs through the provided proxy.

If you would normally make a request to a Google Maps endpoint, instead make the request to the corresponding endpoint on the interview proxy domain.

Given a starting location string and a list of resort names, write code that uses the Maps API to look up the place ID for each location.

START_LOCATION = "556 Jackson St, San Francisco CA 94109"
RESORTS = [
    "Palisades Tahoe",
    "Kirkwood Mountain Resort",
    "Jackson Hole Mountain Resort",
    "A-basin",
]

这道题的核心是把普通的地点查询请求改写为通过 interview proxy 访问地图 API,并为给定的起始地址和一组度假村名称逐个查询对应的 place ID。实现时通常需要使用 requests 发送带有 authorization 等请求头的 HTTP 请求,解析返回的 JSON,并处理接口响应异常。题目重点不在复杂算法,而在于正确拼接请求、读取 JSON 结果、以及在列表场景下批量完成地点检索。

正文完
 0