Category Archives: Python Programs

Introduction of Radix Sort

Radix Sort is the answer when elements are in the range from 1 to n^2. The idea of Radix Sort is to do digit by digit sort starting from least significant digit to most significant digit. Radix sort uses counting sort as a subroutine to sort. Radix Sort: Radix Sort basically consists of the following steps: Take the… Read More »

Reverse each element of an array then sort the array in Python

Given an array arr1[] of size n, so firstly we have to reverse each element of an array, and store each of that reversed element in new arr2[] and then sort. Examples: Input : arr1[]={45,67,98,10} Output : after sorting=>{1,54,76,89} Explanation : arr1[]={45,67,98,10} so after reversing each element: arr2[]={54,76,89,1} after sorting arr2[] becomes: arr2={1,54,76,89} Input : arr1[]={20,56,90,19,42,67} Output :… Read More »

Find length of Longest Consecutive Occurrences of second string that occurs in first string

You are given two strings string1 and string2. Your task is to find length of longest consecutive occurrences of second string that occurs in first string. Examples: Input: string1=”AAACBBAAAA”,  string2=”A” Output: 4 Explanation: We will get AAA(0:3) and then AAAA(6:10) as 4 is greater than 3, answer is 4. Input: string1=”ABBABBABBAAAA”,  string2=”ABB” Output: 9 Approach: Initially find length… Read More »