Category Archives: Algorithms and Data Structures

Palindrome in python

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 …

Read more »

Python anagram solver

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 …

Read more »

Find repeated characters in python

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. # Input string str = “Computers …

Read more »

How to find second largest number in python

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 # Array A = [1, 5, 7, 5] # Initialize first and …

Read more »

Python Power Function

Syntax The power function in Python can be easily computed by importing the math module as follows: import math # This will print 8 which is 2 to the power 3 print pow(2, 3) You can alternatively use the ** …

Read more »

Python for loop

Introduction Any computer algorithm requires two control flow structures: iteration and selection. Our topic today is mainly about iteration using the Python for loop. The goal of this post is to achieve three objectives: Provide a beginner introduction to the …

Read more »

Amicable Numbers

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 …

Read more »

Page 1 of 1612345...10...Last »