The Hamming weight of a string is the number of symbols that are different from the zero-symbol of the alphabet used. It is thus equivalent to the Hamming distance from…
Two strings are called isomorphic if one-to-one mapping is possible for every character of the first string to every character of the second string. Sample Input: s1 = "feel", s2…
In number theory, a happy number is a number which eventually reaches 1 when replaced by the sum of the square of each digit. For instance, 13 is a happy number because 12…
Nim Game is a mathematical game of strategy in which two players take turns removing (or "nimming") objects from distinct heaps or piles. On each turn, a player must remove at least one object,…
Given a total of N regular hexagon , find out how many rows of pyramid we can build. Note that every k-th row must have exactly k hexagon. Sample Input:…
In number theory, a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For instance, 6 has divisors 1, 2 and 3 (excluding itself), and…
Given a list of integers including positive and negative ones, find out the maximum sum from any slice of this list. Sample Input: [3,-2,2,-3,4,-1,2,1,-5,4,-2,2] Sample Output: 6 From the above…
Fibonacci numbers, commonly denoted Fn, form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, and The…