LeetCode – Arrays – Winner in Tic Tac Toe
Tic-tac-toe is played by two players A and B on a 3 x 3 grid. Here are the rules of Tic-Tac-Toe: Given an array moves where each element is another…
Tic-tac-toe is played by two players A and B on a 3 x 3 grid. Here are the rules of Tic-Tac-Toe: Given an array moves where each element is another…
A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance is the…
You are given the array paths, where paths = means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any…
Given an array of string words. Return all strings in words which is substring of another word in any order. String words is substring of words, if can be obtained…
Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring). The score after splitting…
Given alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits). You have to find a permutation of the string where no letter is followed…
Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array…
Given an array of integers arr, replace each element with its rank. The rank represents how large the element is. The rank has the following rules: Example 1: Input: arr…
Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time. Return that integer. Example 1: Input:…
Given a 2D grid of size m x n and an integer k. You need to shift the grid k times. In one shift operation: Return the 2D grid after…