[LeetCode] 706. Design HashMap, Easy

2025. 4. 8. 14:48·CodingTest/LeetCode
반응형

1. 문제

  • 내장 라이브러리를 사용하지 않고 요구사항에 맞는 HashTable을 구현하라.

2. 해결

class MyHashMap {
    map:{}
    constructor() {
        this.map = {};
    }

    put(key: number, value: number): void {
        this.map[key] = value;
    }

    get(key: number): number {
        return this.map[key] === undefined ? -1 : this.map[key];
    }

    remove(key: number): void {
        delete this.map[key]
    }
}

/**
 * Your MyHashMap object will be instantiated and called as such:
 * var obj = new MyHashMap()
 * obj.put(key,value)
 * var param_2 = obj.get(key)
 * obj.remove(key)
 */
저작자표시 (새창열림)
'CodingTest/LeetCode' 카테고리의 다른 글
  • [LeetCode] 136. Single Number, Easy
  • [LeetCode] 217. Contains Duplicate, Easy
  • [LeetCode] 705. Design HashSet, Easy
  • [LeetCode] 236. Lowest Common Ancestor of a Binary Tree, Medium
뜸부깅
뜸부깅
코딩에 대한 여러 개인적인 생각을 정리하고 공부를 하는 공간입니다!!
  • 뜸부깅
    코오오딩
    뜸부깅
  • 전체
    오늘
    어제
    • Note (429)
      • Skill (31)
        • Java & Spring (9)
        • Javascript & HTML & CSS (0)
        • React (0)
        • Next.js (22)
      • CodingTest (389)
        • 백준 온라인 저지(BOJ) (140)
        • 프로그래머스(Programmers) (79)
        • LeetCode (170)
      • Algorithm & Data Structure (6)
      • [Project] 포트폴리오 (3)
        • Front end (3)
        • Back end (0)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    leetcode 2236
    알고리즘
    자바
    백준2751
    medium
    백준
    Easy
    BOJ
    boj2108
    Java
    프로그래머스
    next 14
    백준1260
    백준1427
    백준7576자바
    boj1427
    백준7576
    meidum
    TypeScript
    component-scan
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
뜸부깅
[LeetCode] 706. Design HashMap, Easy
상단으로

티스토리툴바