Skip to content

Instantly share code, notes, and snippets.

const activeBorderRadius = "1rem 1rem 0 0";
const inactiveBorderRadius = "1rem 1rem 1rem 1rem";
const InputContainer = styled.div`
border-radius: ${(props) =>
props.hasText ? activeBorderRadius : inactiveBorderRadius};
`
export const Autocomplete = () => {
const [hasText, setHasText] = useState(false);
// 위의 코드와 겹치는 부분은 생략
const InputContainer = styled.div`
border-radius: ${inactiveBorderRadius};
&.hasText {
border-radius: ${activeBorderRadius};
}
`
export const Autocomplete = () => {
const rotatedArraySearch = function (rotated, target) {
// rotated 배열의 최솟값 인덱스 구하기
const smallest = rotated.findIndex((el) => el === Math.min(...rotated));
const loop = function (min, max) {
while (min <= max) {
let middle = Math.floor((min + max) / 2);
let currentEl = rotated[middle];
if (currentEl < target) {
@Ah-ae
Ah-ae / tree
Last active January 15, 2023 10:52
class Tree {
constructor(value) {
this.value = value;
this.children = [];
}
insertNode(value) {
const childNode = new Tree(value);
this.children.push(childNode);
}
const balancedBrackets = function (str) {
const stack = [];
for (let i = 0; i < str.length; i++) {
const top = stack[stack.length - 1];
switch (str[i]) {
case "[":
stack.push(str[i]);
break;
case "(":
const balancedBrackets = function (str) {
const stack = [];
const open = {
"[": "]",
"(": ")",
"{": "}",
};
const close = "])}";
function getDirections(matrix, from, to) {
// 1. from 노드를 start point로 BFS 순회
// 2. 방문한 노드를 배열에 담아 트래킹하며, 해당 배열에 to 노드가 나오면 true 리턴
// 3. BFS 순회를 마쳤는데 to 노드 안 나오면 false 리턴
const queue = [from],
result = [],
visited = {};
let currentVertex;
.container {
padding: 1rem 0;
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 1.5rem;
}
.mainItem {
grid-row: span 2;
.container {
padding: 1rem 0;
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 1.5rem;
}
/* 태블릿 분기 */
@media screen and (max-width: 1024px) {
// grid container component
const Section = styled.section`
padding: 1rem 0;
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 1.5rem;
@media screen and (max-width: 1024px) {
grid-template-rows: repeat(4, 1fr);
}