Leetcode Progress
Concatenation of Array
Section titled “Concatenation of Array”Problem Statement
Concatenate two arrays side by sideContains Duplicate
Section titled “Contains Duplicate”Problem Statement
Check if an input array contains duplicate elementsValid Anagram
Section titled “Valid Anagram”Problem Statement
Check if two input strings are anagrams of each otherTwo Sum
Section titled “Two Sum”Problem Statement
Given an array of integers, return the indices of the two numbers such that they add up to a specific target.Longest Common Prefix
Section titled “Longest Common Prefix”Problem Statement
Write a function to find the longest common prefix string amongst an array of strings.Group Anagrams
Section titled “Group Anagrams”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”]]
Remove Element
Section titled “Remove Element”Problem Statement
Given an array and a certain value, remove all instances of that value in-place and return the new length.Top K Frequent Elements
Section titled “Top K Frequent Elements”Problem Statement
Given a non-empty array of integers, return the k most frequent elements.Majority Element
Section titled “Majority Element”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.Design Hashset
Section titled “Design Hashset”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]Sort Colors
Section titled “Sort Colors”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]Encode and Decode List of strings
Section titled “Encode and Decode List of strings”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: 3Explanation: The answer is "abc", with the length of 3.Valid Sodoku
Section titled “Valid Sodoku”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