Given a Matrix, get index of rows with K as elements. Input : test_list = [[4, 5, 6], [1, 4, 5], [6, 9, 1], [0, 3 ,1]], K = 6 Output : Read more →
Python Programs
35 postsGenerally, we use swapcase() to swap strings in Python. What if we are asked to do swapping without using the method. In this article, I will be sharing python program to swap Read more →
Given a set, test if any element from range exists in set. Input : test_set = {1, 5, 2, 7, 3, 4, 10, 14}, strt, end = 8, 12 Output : True Read more →
Given a tuple list with probability, get a random tuple. Input : test_list = [(4, 5), (7, 6), (1, 0), (3, 4)], prob_list = [0.4, 0.3, 0.1, 0.2] Output : [(7, 6)] Read more →
Given a binary matrix of order m*n, the task is to find the distance of nearest 1 for each 0 in the matrix and print final distance matrix. From any cell (i,j), Read more →
Given a list of elements p, the task is to convert the whole list into a list of sets. Examples: Input: p = ['apple', 'banana', 'cherry'] Output: [{‘apple’}, {‘banana’}, {‘cherry’}] Explanation : Read more →
Given a number N, the task is to print all duplicate digits of that number in sorted order. Examples: Input: 123412989 Output : 3 4 8 Explanation : The unique digits are Read more →
Given a Rooted Tree with n node, labeled from 1 to n and tree is rooted at node 1. Parent of i-th node is p[i], i is starting from 2 as 1 Read more →
In this article, we will discuss about Hexahectagon number. According to definition of Hexahectagon number: A Hexahectagon number is class of figurate number. It has 600 – sided polygon called Hexahectagon. The Read more →
Given a n*m chess board. We can choose any rectangle formed by board squares and perform an inversion. Every white cell in the inverted rectangle becomes black and every black one becomes Read more →