Data Structure
 Networking
 RDBMS
 Operating System
 Java
 MS Excel
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP
- Selected Reading
 - UPSC IAS Exams Notes
 - Developer's Best Practices
 - Questions and Answers
 - Effective Resume Writing
 - HR Interview Questions
 - Computer Glossary
 - Who is Who
 
Server Side Programming Articles - Page 1981 of 2650
215 Views
Problem statementGiven a binary string, the task is to count the minimum steps to remove substring 010 from this binary stringExampleIf input string is 010010 then 2 steps are requiredConvert first 0 to 1. Now string becomes 110010Convert last 0 to 1. Now final string becomes 110011Algorithm1. Iterate the string from index 0 sto n-2 2. If in binary string has consecutive three characters ‘0’, ‘1’, ‘0’ then any one character can be changed Increase the loop counter by 2Example Live Demo#include using namespace std; int getMinSteps(string str) { int cnt = 0; for (int i = ... Read More
1K+ Views
In this article, we will learn about the solution to the problem statement given below.Problem statement− We are given a number, we need to find the nth multiple of a number k in Fibonacci number.The solution to the problem is discussed below−Example Live Demo# find function def find(k, n): f1 = 0 f2 = 1 i =2; #fibonacci recursion while i!=0: f3 = f1 + f2; f1 = f2; f2 = f3; if f2%k == 0: return n*i ... Read More
 
			
			19K+ Views
Given process, the burst time of a process respectively and a quantum limit; the task is to find and print the waiting time, turnaround time and their respective average time using Shortest Job First Scheduling preemptive method.What is the shortest job first scheduling?Shortest job first scheduling is the job or process scheduling algorithm that follows the nonpreemptive scheduling discipline. In this, scheduler selects the process from the waiting queue with the least completion time and allocate the CPU to that job or process. Shortest Job First is more desirable than FIFO algorithm because SJF is more optimal as it reduces ... Read More
488 Views
Problem statementGiven an array of size n, the task iss to find the minimum number of steps required to make all the elements of the array divisible by 4. A step is defined as removal of any two elements from the array and adding the sum of these elements to the arrayExampleIf input array is {1, 2, 0, 2, 4, 3} then 3 operations are required −1 + 3 = 4 2 + 2 = 4 0 + 4 = 4Algorithm1. Sum of all the elements of the array should be divisible by If not, this task is not possible ... Read More
962 Views
Problem statementGiven a string containing characters as integers only. We need to delete all character of this string in a minimum number of steps where in one step we can delete the substring which is a palindrome. After deleting a substring remaining parts are concatenated.ExampleIf input string is 3441213 then minimum 2 steps requiredFirst remove 121 from string. Now remaining string is 3443Remove remaining string as it’s palindromeAlgorithmWe can use dynamic programming to solve this problem1. Let dp[i][j] denotes the number of steps it takes to delete the substring s[i, j] 2. Each character will be deleted alone or as ... Read More
 
			
			661 Views
Let’s start our article with an explanation of how to find the sum of even factors of a number but what are factors? Factors are the numbers which completely divide the given number leaving zero as remainder or we can say factors are the multiples of the number. Example 1 − If we are given a number 60 Factors of 60 (6*10=2*3*2*5) are 2, 5 and 3 But according to the question, we must find out the sum of even factors so, in the above given example, the even factor will be only 2. Also, if the given number is an ... Read More
319 Views
Problem statementGiven a string, we need to find the minimum number of rotations required to get the same stringExampleIf input string is “bbbbb” then minimum 1 rotation is requiredAlgorithm1. Initialize result = 0 2. Make a temporary string equals to original string concatenated with itself. 3. Take the substring of temporary string of size same as original string starting from second character i.e. index 1 4. Increment the counter 5. Check whether the substring becomes equal to original string. If yes, then break the loop. Else go to step 2 and repeat it from the next indexExample Live Demo#include using ... Read More
340 Views
In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given a number, we need to find all the prime factors of a given number.The efficient solution to the problem is discussed below −Example Live Demo# Python program to print prime factors import math # prime def primeFactors(n): # no of even divisibility while n % 2 == 0: print (2), n = n / 2 # n reduces to become odd for i in range(3, int(math.sqrt(n))+1, 2): # while ... Read More
 
			
			280 Views
In this article, we have an array arr[] of N integers. Our task is to write a program to find the minimum number of elements needed to be removed from the given array so that the sum of the remaining elements is odd. Example The following example demonstrates the minimum number of elements we need to remove from the array for the sum to be odd: Input: arr = {12, 23, 40, 53, 17} Output: 0 Input: arr = {20, 11, 13, 40, 24} Output: 1 The explanation of the above example is ... Read More
528 Views
In this article, we will learn about the solution to the problem statement given below.Problem statement − We are given two integers, we need to display the common divisors of two numbersHere we are computing the minimum of the two numbers we take as input. A loop to calculate the divisors by computed by dividing each value from 1 to the minimum computedEach time the condition is evaluated to be true counter is incremented by one.Now let’s observe the concept in the implementation below−Example Live Demoa = 5 b = 45 count = 0 for i in range(1, min(a, b)+1): ... Read More