LeetCode题目-344

首页 编程分享 LEET_CODE 正文

leetCode 转载 编程分享 2019-11-19 12:53:59

简介 LeetCode题目-344


✏Leetcode之PHP版题目解析(344. Reverse String)


✏描述

写一个函数反转数组中的字符串,要求是只能原地换,也就是说只能使用O(1)的空间复杂度.


✏题目实例


     /**
         * @param String[] $s
         * @return NULL
         */
        function reverseString(&$s) {
            $j=count($s)-1;
            for($i=0;$i<$j;$i++){
                $temp=$s[$i];
                $s[$i]=$s[$j];
                $s[$j]=$temp;
                $j--;
            }; 
            return $s;
        }

转载链接:https://leetcode.cn/


Tags:


本篇评论 —— 揽流光,涤眉霜,清露烈酒一口话苍茫。


    声明:参照站内规则,不文明言论将会删除,谢谢合作。


      最新评论




ABOUT ME

Blogger:袅袅牧童 | Arkin

Ido:PHP攻城狮

WeChat:nnmutong

Email:nnmutong@icloud.com

标签云