분류 전체보기
-
[프로그래머스 level.1] 내림차순정렬, 아스키코드 변환알고리즘 2023. 6. 21. 10:36
문자열내림차순 배열하기 function solution(s) { var answer = ''; let arr = [...s]; let newArr = arr.map(e => e.charCodeAt()).sort((a, b) => b - a) let listArr = newArr.map(e => String.fromCharCode(e)).join("") return listArr; } 내림차순 정렬은 오름차순정렬과는 a, b의 위치만 달라지면 된다 전에는 함수선언문? 으로 되어있었나 그래서 쓸 데 없이 길었는데 화살표 함수로 가독성 좀 높여봤음 아스키코드 변환은 계속해서 사용이 자주 되는데 헷갈림 왔다 갔다 다 좀 기억해두자 아니 근데 남의 풀이보니까 굳이 아스키코드 변환안해도 문자열 자체가 정렬했을 때 ..
-
[CS Study] MVVM && FLUX네트워크/CS Study 2023. 6. 20. 22:59
디자인패턴이란 무엇인가? 디자인패턴이란 소프트웨어의 개발 방법을 공식화 한 것으로 일종의 규칙이다 이를 통해 구현자들 간의 커뮤니케이션의 효능을 높이기 위해서 사용해야 하는 것이다. 이러한 디자인 패턴의 대표적인 예시가 바로 MVVM, FLUX, MVC 와 같은 것들이다. 이것들에 대해서 한번 알아보자! MVVM 과 FLUX의 특징 먼저 뷰를 통해 보여진 내용에 대해서 사용자가 액션을 하게 되면 커멘트 패턴으로 모델뷰에 액션이 전달됩니다 이때 뷰모델은 모델에게 데이터를 요청하게 되고 모델에 요청에 응답하여 데이터를 준 것을 뷰 모델에서 가공하고 저장하게 되고 이걸 뷰가 데이터바인딩해서 화면에 나타나게 한다.장점으로는 의존성을 없애므로 독립적으로 모듈을 개발 할 수 있지만 뷰모델이 상당히 복잡한 구조라는 ..
-
[프로그래머스 level.1] max, 반복되는 인덱스카테고리 없음 2023. 6. 20. 13:58
모의고사 function solution(answers) { const first = [1, 2, 3, 4, 5]; //5 const second = [2, 1, 2, 3, 2, 4, 2, 5]; // 8 const third = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]; //10 let scores = [0, 0 ,0] for (let i = 0; i < answers.length; i++) { if (first[i % 5] === answers[i]) {scores[0] ++}; if (second[i % 8] === answers[i]) {scores[1] ++}; if (third[i % 10] === answers[i]) {scores[2] ++}; } let answer = []..
-
[프로그래머스 level.1] slice 스파르타 예습알고리즘 2023. 6. 20. 11:33
문자열 내맘대로 정렬하기 function solution(strings, n) { var answer = []; for (let i = 0; i < strings.length; i++) { strings[i] = strings[i][n] + strings[i] } strings.sort() for (let i = 0; i < strings.length; i++) { strings[i] = strings[i].slice(1) } return strings; } 문자열 자르는 메서드를 slice()를 썼는데 substr() , subString() 얘네들도 slice()랑 똑같이 작용하고 인자도 똑같은 모습으로 받는것 같아서 slice() 하나만 기억하려고 한다. 스파르타에서 풀었던 문제라서 양심에 찔린다...