All

https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ Best Time to Buy and Sell Stock - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 핵심 아이디어 Sliding window - left, right pointer(index) 이용하여 지역값 구하고, 저장된 max와 비교. 매번 right pointer를 움직이지만, profit 조건이 깨지면 left = right로 초기화 ..
https://leetcode.com/problems/two-sum/ Two Sum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 핵심 아이디어 value: index HashMap을 만들어서 pair(target - num)의 index를 1회당 O(1)에 찾기 배열 탐색과 동시에 hash map 초기 복잡도 시간 복잡도: O(n) 1차원 배열 탐색, hashMap 초기화 O(n) * hashMap get O(1) 공간 복잡도: O(n) 1차원 hashMa..
· React
(업데이트) react router v6.4history.listen을 대체하는 router.subscribe가 업데이트되었습니다. 이를 사용하셔서 구현하시면 됩니다.https://stackoverflow.com/a/71399121/21138374 How to controling browser back button with react router dom v6?I've been looking for this question and found it but they're using class components and react router dom v5 What i want is When user click browser back button I'll redirect them to home pagestacko..
· React
When exactly does React clean up an effect? useEffect()는 리턴값으로 clean up 함수를 전달하여 unmount 할 때의 동작을 설정할 수 있다. 그런데, unmount될 때 동작하면 dependency가 바뀔 때 동작하는 것인지, 아예 렌더링되지 않게 되기 전에 동작하는 것인지 궁금하여 정리했던 내용을 공유한다. Using the Effect Hook - React When exactly does React clean up an effect? React performs the cleanup when the component unmounts. However, as we learned earlier, effects run for every render and ..
문제점 header의 설정값 (global한 값)을 바꾼 뒤 다른 페이지로 이동하면 바꾼 값이 적용되지 않는 현상이 발생했다 원인 header의 설정값은 apollo useQuery를 이용해 불러오고 있었는데, refetch로 변경한 뒤 다시 불러올 때는 예전 캐시 값을 읽어와서 값이 변경되지 않았다. 배경 header에서 사용하고 있던 api 쿼리문은 variable을 전달하지 않으면 가장 마지막에 읽었던 값을, variable을 주면 해당 값을 반환하는 api였다. () => 마지막에 읽었던 값 (variable) => variable에 대응되는 값 이런 상황에서 사용자가 값을 변경하면 두 번째 방법으로 호출하고, 초기에 fetch할 때는 첫 번째 방법으로 호출하여 마지막에 읽었던 값이 반환되기를 기..
· React
React는 svg 파일을 사용할 수 있다. 다른 이미지들처럼
· misc
#꿀팁 git checkout - 위 명령을 사용하면 이전에 작업한(checkout한) 브랜치로 돌아갈 수 있다 더이상 작업하던 feature 브랜치의 이름을 외우지 않아도 된다! 출처
· React
문제 상황 apollo-cli로 graphQL 스키마를 이용해 typescript type을 생성한다. 생성한 타입 정의를 이용하기 위해 프로젝트 폴더/generated/globalTypes.ts 를 소스 파일에서 import 하고 yarn start로 시작하면 You attempted to import ../../../__generated__/globalTypes which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. 와 같은 컴파일 에러가 발생한다 배경 create-react-app으로 생성된 리액트 프로젝트는 src/ 하위에 있는 module만 import할 수 있도록 제..