摘要: 闲来无事,不如试着用ruby刷刷题 1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume 阅读全文
posted @ 2020-07-30 14:02 iTachiLEe 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Array#bsearch bsearch { |x| ... } -> object | nil bsearch -> Enumerator 基于块评估结果来判断范围中的每个元素,并且通过二进制搜索来搜索满足条件的值(计算量为O(log n))。如果找不到该元素,则返回nil。Array 必须事先 阅读全文
posted @ 2020-07-30 10:44 iTachiLEe 阅读(133) 评论(0) 推荐(0) 编辑