Suppose we have an array A. We have to find the maximum length of the subarray, whose LCM is the same as the product of the elements of that subarray. If that kind of subarray is not found, then return -1. Suppose array is {6, 10, 21}, then the length is 2, as the subarray {10, 21} is there, whose LCM is 210, and the product is also 210.The approach is straight forward. We have to check every possible subarray of length greater or equals to 2. If the subarray is satisfying the condition, then update the answer as a ... Read More
Suppose we two integers N and P. The P is the product of N unknown integers. We have to find the maximum possible GCD of those integers. Suppose N = 3, and P = 24, then different groups will be like {1, 1, 24}, {1, 2, 12}, {1, 3, 8}, {1, 4, 6}, {2, 2, 6}, {2, 3, 4}. The GCDs are: 1, 1, 1, 1, 2, 1. So answer is 2 here.We will find all prime factors of P, and store them into hashmap. The N integers will have max GCD when the prime factor will be common in ... Read More
Suppose we two integers N and P. The P is the product of N unknown integers. We have to find the GCD of those integers. There can be different groups of integers possible, that will give the same result. Here we will produce GCD, which is maximum among all possible groups. Suppose N = 3, and P = 24, then different groups will be like {1, 1, 24}, {1, 2, 12}, {1, 3, 8}, {1, 4, 6}, {2, 2, 6}, {2, 3, 4}. The GCDs are: 1, 1, 1, 1, 2, 1. So answer is 2 here.The technique us like, ... Read More
While working with computers, we have a habit of saving a lot of information in our computers such as files, folders, etc. Normally desktop looks like a mess but the problem arises when users want to search a modified file on a particular date or time. There are simple commands which are available in Linux to search a modified file. This article describes “How to Find and Sort Files Based on Modification Date and Time in Linux”.List Files Based on Modification TimeThe list command shows a list of files, directories, information about date and time of modification or access, permissions, ... Read More
The important part of the system administrators is to monitor and examine for a way long Linux system has been strolling. It is a just right concept to hold tracking up time of the Linux systems to optimise the system assets. This article describes Tuptime tool that can help System Administrators to know for how long a Linux machine has been up and running.Tuptime tool is used for reporting the historical and statistical running time (uptime) of Linux systems, which tracks it between restarts.FeaturesRegister the first boot timeTracks System startupsCounts System shutdownsCalculates uptime and downtimeCalculates largest, average, low uptime and downtimePrint ... Read More
This article is for those who believe that Linux command line is boring and there is not much fun. To create an interesting colorful setting lolcat utility can be used, which produces rainbow colors in Linux terminal. Lolcat utility works for Linux, BSD and OSX which concatenates like similar to cat command.Installing LolcatLolcat utility is one of the gem in Ruby programming language. Hence, if you would like to practice this tip, it is essential to install the latest version of Ruby.To install Ruby use the following command –$ sudo apt-get install rubyThe sample output should be like this –Reading package ... Read More
Screen recording is an awesome feature and supposed to be the best way to illustrate something which is happening on your screen. For instance, if you wish to share your own computer screen for giving training or for gaming purpose, this is definitely a much more easier method than setting up a camera in front of the screen and getting a grainy, shaky video. Moreover, screen recorded videos seem much more professional and educational when it comes to teaching, as learning becomes more practical oriented. The viewer knows exactly what to do and where to go. Much better than sitting ... Read More
Given a string and with mixed case, i.e with both uppercase and lower case, the task is to covert the first character to uppercase rest in lowercase if it’s in upper case.Let’s understand it in depth with the help of a simple example.Like we are given a string “hElLo world”, we have to convert the first character ‘h’ which is in lowercase to uppercase ‘H’ and rest all letters before the space or end of the string to lowercase.Moreover when we encounter first character after a space we have to convert it to uppercase.ExampleInput: str[] = {“heLlO wORLD”} Output: Hello ... Read More
Given date in format date, month and year in integer. The task is to find whether the date is possible on not.Valid date should range from 1/1/1800 – 31/12/9999 the dates beyond these are invalid.These dates would not only contains range of year but also all the constraints related to a calendar date.Constraints are −Date can’t be less than 1 and more than 31Month can’t be less than 1 and more than 12Year can’t be less than 1800 and more than 9999When the months are April, June, September, November the date can’t be more than 30.When the month is February ... Read More
Many users are confused whether Linux system’s OS is 32-bit or 64-bit. As we all know, we can’t install 64-bit applications into a 32-bit OS type. Before re-installing Linux or clean Linux, we should verify if Linux system OS is 32-bit or 64-bit. This article guides you about “How to find out Linux operating system system is weather 32-bit or 64-bit”.uname Commanduname is the universal command and it will work on almost all Linux/Unix operating systems. The below command will display your Linux system’s OS type-$ uname -aThe sample output should be like this –$ uname -a Linux linux 4.2.0-30-generic ... Read More