728x90 반응형 Stack2 reverseInParentheses 주어진 문자열에서 괄호로 묶인 부분의 문자열을 뒤집는 함수를 작성하는 문제입니다. 주어진 문자열은 항상 괄호가 올바르게 매치되어 있다고 가정됩니다. 스택을 사용하여 괄호의 시작과 끝을 추적하면서 문자열을 뒤집을 수 있습니다. string solution(string inputString) { char[] ch = inputString.ToCharArray(); Stack stack = new Stack(); int start = 0; int end = 0; for(int i = 0;i 2023. 12. 3. Stacks Stacks are containers of objects based on arrays that follow a Last-In-First-Out (LIFO) order, meaning that the most recently added item is removed first. Stacks are often used with the recursive backtracking algorithm and as the mechanism supporting the “undo” or “back” button in applications and browsers. Compilers often use stacks to parse the syntax of expressions before translating them int.. 2023. 10. 3. 이전 1 다음 728x90 반응형