Home  >  Article  >  Backend Development  >  字符串处理 - php实现字符串反转[首尾交换]

字符串处理 - php实现字符串反转[首尾交换]

WBOY
WBOYOriginal
2016-06-06 20:38:071726browse

php实现字符串反转,不用strrev,不借用数组方式,时间复杂度度小于O(n)的,首尾交换的那种实现。

回复内容:

php实现字符串反转,不用strrev,不借用数组方式,时间复杂度度小于O(n)的,首尾交换的那种实现。

= 0; $i--){
    $tmp .= $str{$};
}

echo $tmp;

貌似不存在O(n/2)这种说法,也还是O(n)

php
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn