面试程序题

齐岳 齐岳 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
一、写一个函数 传入一个数组和N 要求把前N个元素移到最后 需要占用最少内存
比如传入[a b c d e], N=2, 要求返回数组[c d e a b]

二、in case you are not familiar with regular expression substitution, here's a quick tutorial:

the syntax of string substitution is:
VARIABLE =~ s/SEARCH_PATTERN/NEW_STRING/

For example,
$a = 'abc,123';
$a =~ s/(\w+),(\w+)/\2,\1/; # $a is now '123,abc' because \1='abc' and \2='123'

Here's the question:
write ONE substitution statement(ie. s/SEARCH_PATTERN/NEW_STRING/) so that
"<date>1999-02-25</date>" will be updated to "<date>02-25-1999</date>" AND
"<date>2005-11-03</date>" will be updated to "<date>11-03-2005</date>"
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
齐岳
Java 51,407 成员 86,128 内容