Skip to content

Latest commit

 

History

History
51 lines (28 loc) · 1.77 KB

readme.md

File metadata and controls

51 lines (28 loc) · 1.77 KB

Title: Number of Good Pairs

File: good_pairs.scala

Level: easy

Explanation: Given an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j.


Title: Two Sum

File: two_sum.scala

Level: easy

Explanation: 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 use the same element twice. You can return the answer in any order.


Title: Design HashMap

File: my_hash_table.scala

Level: easy

Explanation: Design a HashMap without using any built-in hash table libraries. Implement the MyHashMap class:

  • MyHashMap() initializes the object with an empty map.
  • void put(int key, int value) inserts a (key, value) pair into the HashMap. If the key already exists in the map, update the corresponding value.
  • int get(int key) returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key.
  • void remove(key) removes the key and its corresponding value if the map contains the mapping for the key.

Title: Reverse Number

File: reverse_integer.scala

Level: medium

Explanation:Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned).