Skip to content

Leetcode Progress

Problem Statement Concatenate two arrays side by side
Problem Statement Check if an input array contains duplicate elements
Problem Statement Check if two input strings are anagrams of each other
Problem Statement Given an array of integers, return the indices of the two numbers such that they add up to a specific target.
Problem Statement Write a function to find the longest common prefix string amongst an array of strings.
Problem Statement Given an array of strings, group the anagrams together such that the output is a list of lists of anagrams.

eg. Input: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”] Output: [[“bat”],[“nat”,“tan”],[“ate”,“eat”,“tea”]]

Problem Statement Given an array and a certain value, remove all instances of that value in-place and return the new length.
Problem Statement Given a non-empty array of integers, return the k most frequent elements.
Problem Statement Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
Problem Statement Design a HashSet without using any built-in hash table libraries.

Implement MyHashSet class:

void add(key) Inserts the value key into the HashSet.
bool contains(key) Returns whether the value key exists in the HashSet or not.
void remove(key) Removes the value key in the HashSet. If key does not exist in the HashSet, do nothing.
Input: ["MyHashSet", "add", "add", "contains", "contains", "add", "contains", "remove", "contains"]
[[], [1], [2], [1], [3], [2], [2], [2], [2]]
Output: [null, null, null, true, false, null, true, null, false]
Problem Statement Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. You can use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.
Input: [2,0,2,1,1,0]
Output: [0,0,1,1,2,2]
Problem Statement Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Implement the `encode` and `decode` methods.
Input: ["Hello","World"]
Output: ["Hello","World"]

Length of Longest Substring Without Repeating Characters

Section titled “Length of Longest Substring Without Repeating Characters”
Problem Statement Given a string, find the length of the longest substring without repeating characters.
Input: "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
Problem Statement

You are given a 9 x 9 Sudoku board board. A Sudoku board is valid if the following rules are followed:

Each row must contain the digits 1-9 without duplicates.
Each column must contain the digits 1-9 without duplicates.
Each of the nine 3 x 3 sub-boxes of the grid must contain the digits 1-9 without duplicates.

Return true if the Sudoku board is valid, otherwise return false

Note: A board does not need to be full or be solvable to be valid.

Input: board = [[“1”,“2”,”.”,”.”,“3”,”.”,”.”,”.”,”.”], [“4”,”.”,”.”,“5”,”.”,”.”,”.”,”.”,”.”], [”.”,“9”,“8”,”.”,”.”,”.”,”.”,”.”,“3”], [“5”,”.”,”.”,”.”,“6”,”.”,”.”,”.”,“4”], [”.”,”.”,”.”,“8”,”.”,“3”,”.”,”.”,“5”], [“7”,”.”,”.”,”.”,“2”,”.”,”.”,”.”,“6”], [”.”,”.”,”.”,”.”,”.”,”.”,“2”,”.”,”.”], [”.”,”.”,”.”,“4”,“1”,“9”,”.”,”.”,“8”], [”.”,”.”,”.”,”.”,“8”,”.”,”.”,“7”,“9”]]

Output: true