Arnab Chakraborty has Published 4452 Articles

Program to count number of 5-star reviews required to reach threshold percentage in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 06:19:05

638 Views

Suppose we have a list called reviews and a threshold value t. Each item in reviews[i] has [x, y] means product i had x number of 5-star rating and y number of reviews. We have to find the minimum number of additional 5-star reviews we need so that the percentage ... Read More

Program to count number of similar substrings for each query in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 06:15:35

269 Views

Suppose we have two strings s and a set of query Q. Where Q[i] contains pair (l, r), for each substring of s from l to r, we have to find number of substrings s from x to y where they are similar. Two strings s and t are similar ... Read More

Program to create a lexically minimal string from two strings in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2021 11:29:37

100 Views

Suppose, we have two strings. We want to make a lexically minimum string from those strings. To make the string we compare the first letter of the two strings and extract the lexically smaller letter from one of the strings. In the case of a tie i.e, the letters are ... Read More

Program to find out the number of shifts required to sort an array using insertion sort in python

Arnab Chakraborty

Arnab Chakraborty

Updated on 09-Oct-2021 11:07:25

928 Views

Suppose we are given an array and asked to perform insertion sort on it. In insertion sort, each element in an array is shifted to its correct position in the array. We have to find out the total number of shifts required to sort an array. The total number of ... Read More

C program to sort triangles based on area

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 11:26:27

493 Views

Suppose we have an array of different triangles where triangles[i] = [ai, bi, ci] these are the sides of ith triangle. We shall have to sort the triangles based on their area. The area of a triangle by using sides is: square root of p*(p-a)*(p-b)*(p-c) where p = (a+b+c)/2.So, if ... Read More

C program to find sum, max and min with Variadic functions

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 11:23:16

1K+ Views

Suppose we want to make some functions that can take multiple arguments, there are no fixed number of arguments. We want to make three functions sum(), max() and min(), they can calculate sum of the numbers, maximum of numbers and minimum of given numbers respectively. Each of these functions will ... Read More

C program to find permutations of given strings

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 11:19:50

5K+ Views

Suppose we have few strings in an array. We shall have to find all permutations of them in different line.So, if the input is like strings = ["abc", "def", "ghi"], then the output will beabc def ghi abc ghi def def abc ghi def ghi abc ghi abc def ghi ... Read More

C program to find frequency of each digit in a string

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 11:18:19

4K+ Views

Suppose we have a string s. The s contains letters and digits both. We shall have to find frequencies of each digit and display them. To do this we can make an array of size 10 for each digits (0 through 9), initially all elements are 0 inside the array, ... Read More

C program to print string tokens

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 11:15:09

3K+ Views

Suppose we have a string s that contains a sentence with few words. We shall have to print each word into new lines. To do this we can use the strtok() function under the string.h header file. This function takes the string and a delimiter. Here the delimiter is blank ... Read More

C program to dynamically make array and print elements sum

Arnab Chakraborty

Arnab Chakraborty

Updated on 08-Oct-2021 11:09:20

6K+ Views

Suppose we have a number n. We shall have to make an array of size n dynamically and take n numbers one by one, then find the sum. To make the array we can use malloc() or calloc() function which is present inside the stdlib.h header file. The value of ... Read More

Advertisements