注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
一道shopify当天的新鲜面经,后来发现是一道Leetcode稍微变形的easy题,做倒是误。
原题如下:- /*
- # Write a function that takes a list of integers and outputs a list of pairs
- # representing the consecutive ranges contained in the inputlist
- #
- # test_list1 = [1,3,4]
- # test_output1 = [(1,1),(3,4)]
- #
- # test_list2 = [1,2,3,4,5]
- # test_output2 = [(1,5)]
- #
- # test_list3 = [1,3,4,5,6,7,9]
- # test_output3 = [(1,1), (3,7), (9,9)]
- */
复制代码 |