[LeetCode]문자열 뒤집기

Inhwan98·2023년 1월 8일
0

PTU STUDY_leetcode

목록 보기
2/24

문제

문자열을 뒤집는 함수를 작성하라. 입력값은 문자 배열이며, 리턴 없이 리스트 내부를 직접 조작하라

예제

  • Example 1:
Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]
  • Example 2:
Input: s = ["H","a","n","n","a","h"]
Output: ["h","a","n","n","a","H"]

풀이

class Solution {
public:
    void reverseString(vector<char>& s) {

	reverse(s.begin(), s.end());
    
	}
};

결과

Runtime 28ms / Memory 23.2MB
https://leetcode.com/problems/reverse-string/submissions/879939247/


https://leetcode.com/problems/reverse-string/

profile
코딩마스터

0개의 댓글