stack = []
stack.append()
stack[-1]
stack.pop()
from collections import deque
queue = deque()
queue.append()
queue.popleft()
queue[0]
dict = {"example" : 0, "test" : 1}
// 조회 시
dict["example"]
// 변경 시
dict["example"] = 4
answer.sort(key=lambda x: x[dict["example"]])
import java.util.Stack;
Stack<Integer> stack = new Stack<>();
stack.add(1);
stack.peek();
stack.poll();
import java.util.Queue;
static Queue<int[]> queue = new LinkedList<>();
queue.add({1, 2});
queue.poll();
queue.peek();
import java.util.HashMap;
HashMap<String, Integer> dict = new HashMap<>(){
{
put("example", 0);
put("test", 1);
}
};
//조회 시
dict.get("example");
//변경 시
dict.put("example", 4);
answer.sort((a, b) -> Integer.compare(a[dict.get("example")], b[dict.get("example")]));
import java.util.Comparator;
List<int[]> answer = new ArrayList<>();
Comparator<int[]> customComparator = new Comparator<>() {
@Override
public int compare(int[] a, int[] b) {
return Integer.compare(a[dict.get(sort_by)], b[dict.get(sort_by)]);
}
};
answer.sort(customComparator);
import java.util.Comparator;
int[][] answer = new int[list.size()][4];
Arrays.sort(answer, new Comparator<int[]>() {
@Override
public int compare(int[] s1, int[] s2) {
return s1[dict.get(sort_by)] - s2[dict.get(sort_by)];
}
});
댓글남기기