You are given a 0-indexed string array words. You need to determine the number of index pairs (i, j) such that i < j and the string at index i is both a prefix and a suffix of the string at index j. The function isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.
You are given an integer array ’nums’ of even length. Your task is to determine whether it is possible to divide the array into two subarrays, ’nums1’ and ’nums2’, such that both subarrays have distinct elements and the same length. Each subarray must contain half of the total elements from the original array.
An integer is called a Harshad number if it is divisible by the sum of its digits. You are given an integer x. Your task is to return the sum of the digits of x if x is a Harshad number. Otherwise, return -1.
You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters. Return the score of the string s.
You are given a string word. A letter is considered special if it appears both in its lowercase and uppercase form in the string. Return the number of special letters in word.
You are given a 3x3 matrix consisting of characters ‘B’ (black) and ‘W’ (white). Your task is to determine if it is possible to change the color of at most one cell to form a 2x2 square where all cells are of the same color. Return true if it is possible, otherwise return false.