Given an m x n 2D binary grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time.
3.1 TestCase
Implement a list using an array in JAVA. The list should be able to perform the following operations:
- size.
- isEmpty.
- contains.
- add.
- remove.
- get.
- set.
- clear.
4.1 Test Case
Given a string s, return the longest palindromic substring in s.
Input: s = "babad". Output: "bab". Note: "aba" is also a valid answer.
Input: s = "cbbd". Output: "bb".