Category Archives: Algorithms

Compare Two Lists

In dart programming, Lists are used for the collection of data. We declare just variables instead of declaring a separate variable for each value of the collection. Lists are indexable so that we access the values using index ( starts from 0 ). In this article, we will see how to compare two Lists in the dart.  For… Read More »

Convert Number n to 1 in Minimum Steps

Given a number n (n>=1 && n<=1018), your task is to convert it to 1 in minimum operation and constant space and time complexity. In one operation you can either – Subtract 1 from n if n>1. (or) Divide n by one of its proper divisor. Examples:- Input: n=2 Output: 1 2–>1. first move:- subtract 1 from n… Read More »

Find Words containing ‘a’ in given String

Given a statement(string), the task is to check if that string contains any word which contains ‘a’ in it then print that word otherwise print no any word containing ‘a’ in the inputed string. Examples : Input: “W3Colleges provides excellent tutorials” Output: tutorials Input: “Python is fun” Output: no any word containing ‘a’ in the inputed string Input:… Read More »

Find the Nth Triacontakaihenagonal Number

Given a number N, the task is to find Nth triacontakaihenagonal number. A triacontakaihenagonal number is class of figurate number. It has 31 – sided polygon called triacontakaihenagon. The N-th triacontakaihenagonal number count’s the 31 number of dots and all others dots are surrounding with a common sharing corner and make a pattern. The first few triacontakaihenagonol numbers… Read More »