Programming Articles

Page 172 of 2544

Program to find minimum sum of difficulties to complete jobs over k days in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 232 Views

Suppose we have a list of numbers called jobs and another value k. Now we want to finish all jobs in k different days. The jobs must be performed in the given order and in each day we have to complete one task. The difficulty of job i is stored at jobs[i] and the difficulty of completing a list of jobs on a day will be the maximum difficulty job performed on that day. So we have to find the minimum sum of the difficulties to perform the jobs over k different days.So, if the input is like jobs = ...

Read More

First uppercase letter in a string (Iterative and Recursive) in C++

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 688 Views

In this tutorial, we are going to learn how find the first uppercase letter in the given string. Let's see an example.Input −TutorialspointOutput −TLet's see the steps to solve the problem using iterative method.Initialize the string.Iterate over the string.Check whether the current character is uppercase or not using isupper method.If the character is uppercase than return the current character.ExampleLet's see the code.#include using namespace std; char firstUpperCaseChar(string str) {    for (int i = 0; i < str.length(); i++)       if (isupper(str[i])) {          return str[i];       }       return ...

Read More

Check whether the length of given linked list is Even or Odd in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 249 Views

Suppose we have a linked list, we have to check whether the length of it is odd or even.So, if the input is like head = [5, 8, 7, 4, 3, 6, 4, 5, 8], then the output will be Odd.To solve this, we will follow these steps −while head is not null and next of head is not null, dohead := next of next of headif head is null, thenreturn "Even"return "Odd"Let us see the following implementation to get better understanding −Example Codeclass ListNode:    def __init__(self, data, next = None):       self.val = data     ...

Read More

How to create side by side histograms in base R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 2K+ Views

To create side by side histograms in base R, we first need to create a histogram using hist function by defining a larger limit of X-axis with xlim argument. After that we can create another histogram that has the larger mean and smaller standard deviation so that the bars do not clash with each other and add=T argument must also be added inside the second hist function.Examplehist(rnorm(5000,mean=5,sd=2.1),col="green",xlim=c(1,20))OutputExamplehist(rnorm(5000,mean=15,sd=1.25),col="red",add=T)Output

Read More

Program to justify a set of words by converting them into same length lines in C++

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 126 Views

Suppose we have an list of words and a width k, we have to arrange the text such that each line has exactly k number of characters and the text is fully justified. Here we shall pack our words as many words as we can insert in each line. And we shall pad extra spaces ' ' when necessary so that each line has exactly k characters.Here extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line do not divide evenly between words, empty slots on the left will be assigned ...

Read More

Fixed (or static) Partitioning in Operating System in C++

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 1K+ Views

In this tutorial, we are going to learn about the fixed partitioning in the operating system.Fixed partitioning is one to manage the memory in operating system. It's an old technique. It divides the memory into equal blocks. The size of each block is predefined and can not be changed.The memory is used for the contiguous processes.ExampleLet's see the sample program that allocates memory based on the process size.#include using namespace std; int main() {    int blockNumber = 5, processesNumber = 3;    int blockSize[5] = {4, 4, 4, 4, 4}, processSize[3] = {1, 2, 3};    int flags[5], allocation[5]; ...

Read More

Check whether the number can be made perfect square after adding 1 in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 601 Views

Suppose we have a number n. We have to check whether the number can be a perfect square number by adding 1 with it or not.So, if the input is like n = 288, then the output will be True as after adding 1, it becomes 289 which is same as 17^2.To solve this, we will follow these steps −res_num := n + 1sqrt_val := integer part of square root of(res_num)if sqrt_val * sqrt_val is same as res_num, thenreturn Truereturn FalseLet us see the following implementation to get better understanding −Example Codefrom math import sqrt def solve(n):    res_num ...

Read More

How to convert NA&rsquo;s in sequence to a single NA in an R vector?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 158 Views

Sometimes values are missing in a sequence and R program records them as NA (Not Available). In this type of situation, we might want to replace consecutive NA records with single NA value. This can be done by using is.na along with diff function as shown in the below examples.Examplex1

Read More

Program to find lexicographically smallest subsequence of size k in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 381 Views

Suppose we have a list of numbers called nums and another value k, we have to find the lexicographically smallest subsequence of size k.So, if the input is like nums = [2, 3, 1, 10, 3, 4] k = 3, then the output will be [1, 3, 4]To solve this, we will follow these steps −l := size of nums, r := k - 1out := a new listfor j in range 0 to k, domn := nums[complement of r]for i in range r to l, doif mn >= nums[complement of i], thenmn := nums[complement of i]l := ir := ...

Read More

Check if a point lies on or inside a rectangle in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 6K+ Views

Suppose we have a rectangle represented by two points bottom-left and top-right corner points. We have to check whether a given point (x, y) is present inside this rectangle or not.So, if the input is like bottom_left = (1, 1), top_right = (8, 5), point = (5, 4), then the output will be TrueTo solve this, we will follow these steps −Define a function solve() . This will take bl, tr, pif x of p > x of bl and x of p < x of tr and y of p > y of bl and y of p < ...

Read More
Showing 1711–1720 of 25,433 articles
« Prev 1 170 171 172 173 174 2544 Next »
Advertisements