String palindrome in python Write python code to find palindrome strings. A Palendrome string can be read the same from either direction left to right or right to left. Palindrome python code Here is a palindrome algorithm python code. You may also checking this post for a C++ implementation. Thanks for visiting. Please use the
Anagram solver in python Two strings are anagrams if they contain the same set of characters regardless of the order of individual characters such as “earth” and “heart”. Write python code to detect if two strings are anagrams. Python anagram solver code Here is the code in python. You may also check this solution in
Python repeated character in string Given a string of characters. Write python code to print the repeated characters Solution This is a typical dictionary based problem. Here is how to do that in Python. You may need to take a look at the following similar articles Character count in string java String repeated characters count
Second largest number python problem Given an array of numbers, write python code to find second largest number in array Code to find second largest number in list A C++ version can also be found here. Thanks for visiting. Please use the comments section for feedback.
Syntax The power function in Python can be easily computed by importing the math module as follows: You can alternatively use the ** syntax as follows: Modular Exponentiation The power function can also be used as: This is called modular exponentiation which is useful in some computer science applications especially public key cryptography, for example:
Amicable Numbers Definition Two positive integer numbers (m, n) are amicable if the sum of the proper divisors of (m) is equal to (n) and the sum of the proper divisors of (n) is equal to (m). A proper divisor of a number does not include the number itself. For example, the proper divisors of
Problem Given the signature of the method below. It receives a two dimensional array of strings. Provide implementation that iterates through each string in each sub-array in the order they are provided but it skips null values Solution We are dealing with a two dimensional array of strings so we need a proper way to
Problem Given the Java method signature below. It receives an array of string iterators. The method should return a single string iterator that chains all iterators in order skipping null values Solution We wrap the array of iterators in a list that implements the iterable interface and override the hasNext, next and remove methods. hasNext:
Problem Given the signature of the Java method below Provide implementation that iterates through each string in the order that they are provided but it skips null values Solution We implement the Iterable interface. We add a class member variable to store the list values in an array of strings. We override hasNext, next and
Problem Given the cache interface below We want to implement a generic cache class in order to improve compile time type checking. Solution Using Java Generics one can provide variable types as parameters for compile time type checking. In this case we are going to use K for key and V for value as follows