We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1. Given an integer array nums, return the length of its longest harmonious subsequence among all its possible subsequences. A subsequence of array is a sequence
You have n candies, the ith candy is of type candies[i]. You want to distribute the candies equally between a sister and a brother so that each of them gets n / 2 candies (n is even). The sister loves to collect different types of candies, so you want to give her the maximum number of diff
Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. Example: Input: ["Hello", "Alaska", "Dad", "Peace"]<br />Output: ["Alaska", "Dad"]<br /> Note: You may use one charact
ou are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island (i.e., one or more connect
Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters). Find the number of boomerangs. You may assume that n will be at most 500 and
एनबीए के एक अधिकारी ने खुलासा किया है कि बॉलीवुड की सभी चार अभिनेत्रियों, दीपिका पादुकोण, सारा अली खान, रकुल सिंह और श्रद्धा कपूर, जिनसे हाल ही में नारकोटिक्स कंट्रोल ब्यूरो (एनसीबी) ने पूछताछ की थी, ने मादक द्रव्यों के सेवन से इनकार किया है। उन्होंने कहा कि वे अपने व्हाट्सएप संदेशों में हाथ से ल
Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example, "Aa" is not considered a palindrome here. Example 1: Input: s = "abccccd
Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that was added in t. Example: Input:<br />s = "abcd"<br />t = "abcde" Output:
Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,1], nums2 = [2,2]<br />Output: [2,2]<br />Example 2: Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4]<br />Output: [4,9]<br />Note: Each element in the result should appear as
Given a pattern and a string s, find if s follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in s. Example 1: Input: pattern = "abba", s = "dog cat cat dog"<br />Output: true<
Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "anagram", t = "nagaram"<br />Output: true<br />Example 2: Input: s = "rat", t = "car"<br />Output: false<br />Note:<br />You may assume the string contains only lowercase
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the