๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
T = int(input()) | |
for _ in range(T): | |
s = input() | |
n = len(s) | |
open = 0 | |
YES = True | |
for i in range(n): | |
if s[i] == '(': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
T = int(input()) | |
for _ in range(T): | |
s = input() | |
n = len(s) | |
stack = [] | |
YES = True | |
for i in range(n): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
arr = list(map(int, input().split())) | |
stack = [] | |
answer = [-1 for _ in range(n)] | |
for i in range(n): | |
while len(stack) and stack[-1][0] < arr[i]: | |
answer[stack[-1][1]] = arr[i] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
h = [int(input()) for _ in range(n)] | |
h.append(10 ** 20) | |
n += 1 | |
answer = 0 | |
stack = [] | |
for i in range(n): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stack = [0 for _ in range(10000)] | |
top_index = -1 | |
def push(n): | |
global top_index | |
top_index += 1 | |
stack[top_index] = n | |
def pop(): | |
global top_index |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stack = [] | |
stack.append(5) | |
stack.pop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stack = [] | |
stack.append(5) | |
stack.pop() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
class Main { | |
public static void main(String[] args) { | |
ArrayList<Integer> arr = new ArrayList<>(); | |
for(int i = 0; i <= 5; i++) | |
arr.add(i); | |
arr.add(6); // O(1) | |
arr.remove(arr.size() - 1); // O(1) ์ ์ผ ๋ง์ง๋ง ์์๋ฅผ ์ญ์ ํ๊ธฐ ๋๋ฌธ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
signed main() { | |
vector<int> arr{0, 1, 2, 3, 4, 5}; | |
arr.push_back(6); // O(1) | |
arr.pop_back(); // O(1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [0, 1, 2, 3, 4, 5] | |
arr.insert(3, 6) # O(N) | |
print(arr) # [0, 1, 2, 6, 3, 4, 5] |