【文件属性】:
文件名称:Hashmap
文件大小:6KB
文件格式:ZIP
更新时间:2021-03-09 00:00:25
Ruby
哈希图练习
在这套练习中,您将练习使用哈希解决面试风格的问题。
逢星期一****晚上7点
数组交集
设计并实现一种方法,该方法采用两个具有唯一值的整数数组,然后在新数组中返回它们的交集。
注意:请勿使用&运算符。
例如:
intersection([2, 3, 4], [4, 5, 6]) => [4]
intersection([50, 43, 25, 72], [25, 36, 43, 50, 80]) => [50, 25, 43]
intersection([9, 30, 42], [56, 34, 90, 32]) => []
检查排列
编写一个将两个字符串作为参数的方法,如果一个字符串是另一个字符串的排列,则返回true。
permutations?("hello", "ehllo") => true
permutations?("pasta", "atsap") =
【文件预览】:
Hashmap-master
----Dockerfile(504B)
----test.sh(17B)
----LICENSE(1KB)
----feedback.md(732B)
----README.md(1KB)
----lib()
--------array_intersection.rb(95B)
--------permutations.rb(103B)
--------palindrome_permutation.rb(53B)
----Gemfile(163B)
----Rakefile(158B)
----test()
--------array_intersection_test.rb(495B)
--------permutations_test.rb(746B)
--------palindrome_permutation_test.rb(695B)
--------test_helper.rb(301B)