본문 바로가기

전체 글

(49)
[자료구조] 해시 테이블(hash table) 구현하기 Feat. 자바스크립트 1. 해싱이란? 해시 테이블에 대해 알기 위해선 먼저 해싱에 대해서 알아야 합니다. 해싱이란 어떠한 임의 길이의 데이트를 해싱 함수를 이용해서 고정된 크기의 값으로 변경하는 작업을 뜻합니다. 우리가 개발하면서 흔히 사용하는 jwt 토큰의 경우도 이러한 해싱을 이용하는데 어떤 데이터를 넣어도 고정된 길이의 값의 해싱값으로 변경해서 보내줍니다. 이를 사진으로 표현하면 다음과 같습니다. 2. 그렇다면 해시 테이블은? 해시 테이블이란 이렇게 값을 해싱해 주는 해시함수를 사용하여 반환값을 인덱스로 사용하여 key, value를 저장하는 자료구조를 말합니다. 만약 {key : milk , value : 2023-09-05}라는 값을 해시테이블에 저장한다면 key 해당하는 값을 해싱하여 나온 값이 22라는 정수라 한..
[Java Script]LeetCode 1. Two Sum 1. 문제 개요 문제 링크 : 1. Two Sum Two Sum - LeetCode Can you solve this real interview question? Two Sum - Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not leetcode.com 주어진 값이 배열내의 몇번째 인자끼리의 합으로 만들어진 값인지 구하여라 2. 문제 풀이 간단하게 풀이하면 각각의 요소를 더했을때 결과값이 나오는지 ..
[Java Script]LeetCode 242. Valid Anagram 1. 문제 개요 문제 링크 : 242. Valid Anagram Valid Anagram - LeetCode Can you solve this real interview question? Valid Anagram - Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using leetcode.com 주어진 문자열이 서로 anagram 인지 체크하는 문제입니다. 에너그럼의 정의는 아래 사진과 같은데 문장을 구성한 문자의..