-
항해 99 5기 TIL_37항해 99 2022. 2. 16. 02:06
▶ Today I Learned
<CS>
렉시컬 환경: 식별자-변수 형태의 맵핑 데이터 구조, 자바스크립트 내 메모리이다.
모든 함수와 변수 선언들은 이곳에 저장된다. 즉, 프로그램이 실행되는 동안 함수와 변수가 존재하는 장소
호이스팅이 일어나는 것들이 해당 메모리에 저장된다고 보면 되겠다.
cf) 호이스팅이란?
컴파일 단계 동안 변수와 함수가 스캔되어 렉시컬 환경에 저장되는 현상, 코드 순서상 실제 선언 전이라도
해당 변수나 함수를 사용할 수 있게 된다.
cf) 변수의 호이스팅이 궁금하다면 이 링크를 참조해보자.
https://yceffort.kr/2020/05/var-let-const-hoisting
LexicalEnvironment = { Identifier: <value>, Identifier: <function object> ... }
식별자는 함수/변수 이름을 참조하고 변수는 실제 객체 또는 원시값을 참조한다.
참조:
https://velog.io/@bisu8018/hoisting-in-modern-javascript
<알고리즘>
[큰 수 만들기]
소요 시간: 1시간 25분
해결 여부: 미해결
https://programmers.co.kr/learn/courses/30/lessons/42883
/* 문자열 순서 유지, 중복값은 배열에 넣을 필요는 없음 */ let number = "1924" let k = 2 // // 주어진 문자열 내 최댓 값 찾기 // let max = arr.reduce((a, b) => Math.max(a,b)) // console.log(number.split(max)) // number.split('') // let arr2 // if (k < number.split(max)[1].length) { // while(j < k) { // arr2 = number.split(max)[1].split('') // push Math.max(...arr2) // j++ // } // } let arr = number.split('') let i = 9 let arr2 = [] let j = 0 while ( arr2.length < arr.length - k) { if (arr[j] == i) { arr2.push(i) } j++ if (arr.length == j) { j = 0 i-- } } let answer = arr2.join('') +''
첫 번째 테스트는 통과했지만 그 다음 테스트 케이스들은 모두 떨어졌다.
문자열 내 순서를 고려한 식이라 생각했지만 사실 그런 식이 아니었던 것이다..
생각보다 간단한 문제라 하여 우선 조금 더 생각해보아야 겠다.
<git.ignore>
깃헙에 올리고 싶지 않은 파일이 있다면 그것을 git.ignore라는 곳에 올려주어야 한다.
이때 예를 들어 올리고 싶지 않은 폴더 명이 test 라면 test/라고 써주면 된다.
이렇게 되면 해당 폴더 및 하위에 있는 폴더들 까지 모두 무시된다.
단, 이전에 깃헙에 해당 폴더가 실수로 올라간 적이 있다면
git.ignore에 넣어도 무시되지 않는다고 한다.
이때는 해당 폴더의 캐시를 터미널에서 지워주어야 한다.
명령어는 아래와 같다고 한다.
// 파일일 경우 git rm --cached test.txt // txt라는 확장자로 된 파일 전부 선택할 경우 git rm --cached test.txt // 폴더일 경우 git rm --cached test/ -r // + 그리고 폴더 명이 .env copy 처럼 공백이 있을 경우는 .env\ \copy를 해주어야 한다. // 특수 문자를 저렇게 하여야 인식이 된다는 팀원의 조언이 있었다.
출처:
▶ 느낀 점
알고리즘의 길도 참 갈 길이 멀다
레벨 2는 정말 수준이 확 달라진게 느껴졌다.
그래도 하나씩 풀어나가다보면 실력은 분명히 늘 것이다.
수학시간에도 처음에 풀지 못했던 문제를 졸업 즈음엔 모두 능숙하게 풀어냈던 것처럼 말이다!
+
꽤 공부시간을 채워 공부했지만 많이 공부한 느낌이 들지 않는다..
코딩할 때 생각보다 시간대비 많은 걸 하지 못한 것 같다
전날 밤을 새서 조금 정신이 없기도 했지만 오늘은 자고
내일 조금 더 열심히 해보자 :)
▶ 공부 시 참고 링크들
https://m.blog.naver.com/asdf2017/221574655738
https://www.daleseo.com/js-node-process-env/
'항해 99' 카테고리의 다른 글
항해 99 5기 TIL_39 (0) 2022.02.18 항해 99 5기 TIL_38 (0) 2022.02.17 항해 99 5기 TIL_36 (0) 2022.02.15 항해 99 5기 WIL_5 (0) 2022.02.13 항해 99 5기 TIL_35 (0) 2022.02.13