Sort Array According to Another Array using Pair in C++

Arnab Chakraborty
Updated on 21-Oct-2019 12:20:28

934 Views

Suppose we have two different arrays. We have to sort one array based on the other array using C++ STL pair class. Consider two arrays are like A1 = [2, 1, 5, 4, 9, 3, 6, 7, 10, 8], and another array is like A2 = [A, B, C, D, E, F, G, H, I, J], The output will be like: A1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], A2 = [B, A, F, D, C, G, H, J, E, I]Here we are using the pairs of C++ STL. The pair is formed by taking one ... Read More

Increase Number of Maximum Open Files in Linux

Samual Sam
Updated on 21-Oct-2019 12:18:56

1K+ Views

If you are working on Linux, then you must have encountered many-a-time with “Too many open files (24)” error. Linux operating system provides a way of limiting the amount of files that can be used by every user. This article provides insights on how to increase the number of open files or file descriptors in Linux operating system.The ulimit command has the control over shell or processes and it should require a login as the root user. The ulimit command is used to set the file limits that apply only to your current session.Use the following command to display the ... Read More

Sort Array of Strings by Another String in C++

Arnab Chakraborty
Updated on 21-Oct-2019 12:18:01

401 Views

Suppose we have an array of strings, and another string is there for the reference. We have to take the reference string and using the order of the characters in the reference string we will sort the string array. Here we are considering the strings in the array, and the reference string is in lower case letters.Suppose the string array is like: [“hello”, “programming”, “science”, “computer”, “india”], the reference string is like: “pigvxbskyhqzelutoacfjrndmw”, After sorting the output string will be like [“programming”, “india”, “science”, “hello”, “computer”]The task is simple. We have to traverse the reference string, then store the character ... Read More

Sort Elements of Array Between Multiples of K in C++

Arnab Chakraborty
Updated on 21-Oct-2019 12:15:15

182 Views

Suppose we have an array A, and another integer K. We have to sort the elements that are in between any two multiples of K. Suppose A is like [2, 13, 3, 1, 21, 7, 8, 13, 12], and K = 2. The output will be [2, 1, 3, 7, 13, 21, 8, 13, 12]. Here multiple of 2 are 2, 8 and 12, the elements in between 2 and 8 are 13, 3, 1, 21, 7, they will be sorted as 1, 3, 7, 13, 21, the elements between 8 and 12 is only 13, so that is already ... Read More

Best Presentation Tools for Business

Samual Sam
Updated on 21-Oct-2019 12:14:48

278 Views

It is not uncommon to see many people trying their hands at tools such as PowerPoint and Prezi to deliver everlasting presentations. More often than not, they end up whacking their brains to make their presentations all the more impressive.Call it an all-consuming obsession of a connoisseur, PowerPoint and Prezi no longer holds candle to the several viable alternatives available in the market. There are several new kids on the block. One should definitely give a shot to each of the below mentioned alternatives. Here is a comprehensive and a curated list on the best Prezi alternative tools −EmazeLet me ... Read More

Prevent Fork Bomb by Limiting User Processes in Linux

Samual Sam
Updated on 21-Oct-2019 12:11:38

395 Views

A Fork Bomb is a denial-of-service (DoS) attack against a Linux based system. It makes use of the fork operation to create infinite processes and is called as “Rabbit Virus or wabbit”. The system process continually replicates itself to deplete available system resources, causing resource starvation, slowing or crashing the system. This article gives insights on – how to prevent a fork bomb attack in Linux system.Fork Bomb uses a bash code and gets executed repeatedly. Linux system admin often uses bash function to test the user process limitations and this specific process can be configured in /etc/security/limits.conf file. Once Fork ... Read More

Monitor Linux Server Performance Remotely Using Web Browser

Samual Sam
Updated on 21-Oct-2019 12:07:49

422 Views

Are you looking for speedy server statistics monitoring script? If yes, then this article is for you. Here, we will be explaining about Linux-dash which is a memory efficient, low resource, easy to install, server statistics monitoring script written in PHP.An internet static web page allows you to rearrange various widgets as you want. This script displays residing records of your server, including RAM, CPU, Disk space, community understanding, mounted programs, going for walks approaches and rather more.Linux Dash FeaturesLinux Dash Features should be like this –It is a lightweight and responsive web-based interface for monitoring server resourcesEasy to install ... Read More

Check If a Number is Divisible by Any of Its Digits in C

Sunidhi Bansal
Updated on 21-Oct-2019 11:59:18

2K+ Views

Given a number n, task is to find that any of the digit in the number divides the number completely or not. Like we are given a number 128625 is divisible by 5 which is also present in the number.ExampleInput: 53142 Output: yes Explanation: This number is divisible by 1, 2 and 3 which are the digits of the number Input: 223 Output: No Explanation: The number is not divisible by either 2 or 3The approach used below is as follows −We will start from the unit place and take the unit place’s number.Check whether the number is divisible or ... Read More

C Program for Product of Array

Sunidhi Bansal
Updated on 21-Oct-2019 11:53:57

10K+ Views

Given an array arr[n] of n number of elements, the task is to find the product of all the elements of that array.Like we have an array arr[7] of 7 elements so its product will be likeExampleInput: arr[] = { 10, 20, 3, 4, 8 } Output: 19200 Explanation: 10 x 20 x 3 x 4 x 8 = 19200 Input: arr[] = { 1, 2, 3, 4, 3, 2, 1 } Output: 144The approach used below is as follows −Take array input.Find its size.Iterate the array and Multiply each element of that arrayShow resultAlgorithmStart In function int prod_mat(int arr[], ... Read More

C Program for Arrow Star Pattern

Sunidhi Bansal
Updated on 21-Oct-2019 11:49:31

2K+ Views

Given a number n and we have to print the arrow star pattern of maximum n number of stars.The star pattern of input 4 will look like −ExampleInput: 3 Output:Input: 5 Output:The approach used below is as follows −Take input in integer.Then print n spaces and n stars.Decrement till n>1.Now increment till n.And print spaces and stars in increasing order.AlgorithmStart In function int arrow(int num)    Step 1-> declare and initialize i, j    Step 2-> Loop For i = 1 and i

Advertisements