Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack.
Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.
You are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing the left and the right side of the deleted substring to concatenate together.
We repeatedly make k duplicate removals on s until we no longer can.
Return the final string after all such duplicate removals have been made. It is guaranteed that the answer is unique.
Implement the RandomizedSet class:
You must implement the functions of the class such that each function works in average O(1) time complexity.
Given the head of a linked list, return the list after sorting it in ascending order.
You are given an n x n binary matrix grid where 1 represents land and 0 represents water.
An island is a 4-directionally connected group of 1's not connected to any other 1's. There are exactly two islands in grid.
You may change 0's to 1's to connect the two islands to form one island.
Return the smallest number of 0's you must flip to connect the two islands.