LeetCode

LeetCode

HashTable LinearProbing 구현

HashTable을 LinearProbing으로 구현해 보았습니다. 해시테이블이란? 해시 테이블은 (Key, Value)로 데이터를 저장하는 자료구조 중 하나로 빠르게 데이터를 검색할 수 있는 자료구조입니다. 삽입,조회,삭제가 O(1)안에 가능하여 많이 사용됩니다. 구현 방법에는 링크드 리스트를 이용하는 방법과 LinearProbing방법이 있습니다. 링크드리스트를 이용해 구현하는 방법은 인터넷상에 잘 나와있기 때문에 LinearProbing방법으로 구현해 보겠습니다. 메서드 hashfunction put get remove isEmpty 구현 Key와 Value 형테로데이터를 저장하기위한 클래스 Entry를 선언합니다. public class Entry { K key; V value; public En..

LeetCode

[LeetCode] 162. Find Peak Element

Find Peak Element - LeetCode Can you solve this real interview question? Find Peak Element - A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, leetcode.com int 배열에서 좌,우 요소보다 큰 요소의 인덱스를 반환하는 문제입니다. O(log n) 시간 내에 실행되는 알고리즘을 작성해야 합니다. Example 1: Input: nums..

LeetCode

[LeetCode] 148. Sort List

https://leetcode.com/problems/sort-list/description/?envType=study-plan-v2&envId=top-interview-150 Sort List - LeetCode Can you solve this real interview question? Sort List - Given the head of a linked list, return the list after sorting it in ascending order. Example 1: [https://assets.leetcode.com/uploads/2020/09/14/sort_list_1.jpg] Input: head = [4,2,1,3] Output: [1, leetcode.com 링크드 리스트의 헤드..

LeetCode

[LeetCode] 150. Evaluate Reverse Polish Notation

Evaluate Reverse Polish Notation - LeetCode Can you solve this real interview question? Evaluate Reverse Polish Notation - You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation [http://en.wikipedia.org/wiki/Reverse_Polish_notation]. Evaluate t leetcode.com 역 폴란드어 표기법(후위 표기법)으로 산술식을 나타내는 문자열 토큰 배열이 주어집니다. 산술식을 계산하여 최종값을 리턴하는 문제입니다. Example ..

Sol b
'LeetCode' 카테고리의 글 목록 (4 Page)