Reverse a string in Java, in O(1)?

后端 未结 10 2013
被撕碎了的回忆
被撕碎了的回忆 2020-12-31 01:47

Is there any facility in the standard Java libraries that, given a CharSequence, produces the reverse in O(1) time?

I guess this is \"easy\" to implement, just wond

10条回答
  •  误落风尘
    2020-12-31 02:22

    for (count = str.length()-1; count >= 0; count--) {
         tempStr = tempStr.concat(Character.toString(origStr.charAt(count)));
    }
    

提交回复
热议问题