본문 바로가기 메뉴 바로가기

Studying programming

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Studying programming

검색하기 폼
  • Jimin's Programming (194)
    • Algorithms (54)
    • JavaScript (16)
    • Vue.js (3)
    • Node.js (3)
    • React.js (7)
    • React Native (0)
    • Spring Boot (13)
    • JAVA (58)
    • C++ (17)
    • Programming (19)
    • Computer basics (4)
  • 방명록

Algorithms (54)
Using array.reduce method to count duplicate elements

const alphabets = [1,1,1,2,3,3,1,4,5]; const counts = alphabets.reduce((acc, current) => { if(acc[current]){ acc[current] += 1; } else { acc[current] = 1; } return acc; }, {}); console.log(counts); //{ '1': 4, '2': 1, '3': 2, '4': 1, '5': 1 }

Algorithms 2022. 10. 23. 14:27
find intersection algorithm

중복된 값 string return. function FindIntersection(strArr){ let first = strArr[0].split(','); // turn them into array let second = strArr[1].split(','); //중복되는 value 찾기. let filtered = first.filter(function (value){ return second.includes(value) //case-sensitive. return true if it contains the value. }) //중복없으면 return false. if(filtered.length === 0){ return false; }else{ //array to string using joi..

Algorithms 2021. 3. 28. 23:41
two sum

function twoSum(numArr, target) { //Create new Map const numMap = new Map(); //Loop with index for (const [index, element] of numArr.entries()) { //array iterator that returns key/value for each index. //need to calculate the difference so we can compare with array elements const diff = target - element //If our numMap can find the current element which matches the diff, return the array if (num..

Algorithms 2021. 3. 26. 23:34
on sale products algorithm

문제. original price에서 1개 이상을 살때마다 그 다음 product는 sale에 해당되는 할인가를 계속 적용한다. 그 할인된 가격이 limit과 같아지면 할인을 멈추고 총 budget 만큼 합계가 되면 총 몇개의 게임을 샀는지 total game count 를 return 한다. let original = 20; let sale = 3; let limit = 6; let budget = 80; function Sales(o,s,l,b){ let total = o; //여기서 시작이라서. let count = 0; while(total

Algorithms 2021. 2. 12. 16:34
How many typos in a string

연속된 SOS String에 몇개의 typo가 있는지 알아내는 문제 let s = "SOFSOSSISSOW"; function checkTypo(s) { let sosCount = s.length/3; //몇개의 덩어리인지 check. let sosStr = "SOS".repeat(sosCount); //그 덩어리만 제대로된 SOSSOSSOS print let err = 0; //string 도 for loop. for(let i = 0; i < s.length; i++){ if(s[i] !== sosStr[i]){ err++; } } console.log(err); } checkTypo(s); //3

Algorithms 2021. 2. 12. 14:46
CamelCase

WHAT I LEARNED using regular expression split() - The separator can also be a regular expression. 정규식을 split()의 separator로 사용가능. let s = "camelCaseHowManyWords" function CamelCase(str) { let re = /[A-Z]/g; //g is global //regular expression can separate a string at the instance there is a capitalized letter. let wordSplit = str.split(re); let result = wordSplit.length; console.log(result); //5 }..

Algorithms 2021. 2. 12. 14:41
이전 1 2 3 4 ··· 9 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • spring boot application
  • C++
  • hackerrank javascript solution
  • equals()
  • HashMap
  • easy algorithm
  • easy javascript algorithm
  • Object type casting
  • 프로그래머스 알고리즘문제
  • 프로그래머스
  • Collection Framework
  • hackerrank solution
  • ... in Javascript
  • javascript
  • string class in java
  • HackerRank Algorithm
  • algorithm
  • java
  • math.max
  • Javascript Algorithm
  • rest parameter
  • substring()
  • repeat()
  • 알고리즘
  • compareTo()
  • 프로그래머스 알고리즘
  • hackerrank javascript
  • code refactoring
  • math.abs
  • hackerrank
more
«   2025/06   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바