Problem 344 Reverse String
<iframe
src="https://carbon.now.sh/embed/?bg=rgba(171%2C%20184%2C%20195%2C%201)&t=seti&wt=none&l=text%2Fx-c%2B%2Bsrc&ds=true&dsyoff=20px&dsblur=68px&wc=true&wa=true&pv=56px&ph=56px&ln=false&fm=Hack&fs=14px&lh=133%25&si=false&code=class%2520Solution%250A%257B%250Apublic%253A%250A%2509string%2520reverseString(string%2520s)%250A%2509%257B%250A%2509%2509int%2520first%2520%253D%25200%253B%250A%2509%2509int%2520last%2520%253D%2520s.size()-1%253B%250A%2509%2509while%2520(first%2520%253C%2520last)%250A%2509%2509%257B%250A%2509%2509%2509char%2520temp%2520%253D%2520s%255Bfirst%255D%253B%250A%2509%2509%2509s%255Bfirst%255D%2520%253D%2520s%255Blast%255D%253B%250A%2509%2509%2509s%255Blast%255D%2520%253D%2520temp%253B%250A%2509%2509%2509first%252B%252B%253B%250A%2509%2509%2509last--%253B%250A%2509%2509%257D%250A%2509%2509return%2520s%253B%250A%2509%257D%250A%257D%253B&es=2x&wm=false"
style="transform:scale(0.7); width:1024px; height:473px; border:0; overflow:hidden;"
sandbox="allow-scripts allow-same-origin">
</iframe>
<iframe
src="https://carbon.now.sh/embed/?bg=rgba(171%2C%20184%2C%20195%2C%201)&t=seti&wt=none&l=text%2Fx-c%2B%2Bsrc&ds=true&dsyoff=20px&dsblur=68px&wc=true&wa=true&pv=56px&ph=56px&ln=false&fm=Hack&fs=14px&lh=133%25&si=false&code=class%2520Solution%250A%257B%250Apublic%253A%250A%2509string%2520reverseString(string%2520s)%250A%2509%257B%250A%2509%2509int%2520first%2520%253D%25200%253B%250A%2509%2509int%2520last%2520%253D%2520s.size()-1%253B%250A%2509%2509while%2520(first%2520%253C%2520last)%250A%2509%2509%257B%250A%2509%2509%2509char%2520temp%2520%253D%2520s%255Bfirst%255D%253B%250A%2509%2509%2509s%255Bfirst%255D%2520%253D%2520s%255Blast%255D%253B%250A%2509%2509%2509s%255Blast%255D%2520%253D%2520temp%253B%250A%2509%2509%2509first%252B%252B%253B%250A%2509%2509%2509last--%253B%250A%2509%2509%257D%250A%2509%2509return%2520s%253B%250A%2509%257D%250A%257D%253B&es=2x&wm=false"
style="transform:scale(0.7); width:1024px; height:473px; border:0; overflow:hidden;"
sandbox="allow-scripts allow-same-origin">
</iframe
补充内容 (2019-2-21 21:47):
class Solution
{
public:
string reverseString(string s)
{
int first = 0;
int last = s.size()-1;
while (first < last)
{
char temp = s[first];
s[first] = s[last];
s[last] = temp;
...
补充内容 (2019-2-21 21:47):
class Solution
{
public:
string reverseString(string s)
{
int first = 0;
int last = s.size()-1;
while (first < last)
{
char temp = s[first];
s[first] = s[last];
s[last] = temp;
... |