
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
Found 26504 Articles for Server Side Programming

233 Views
Given two numbers start and end representing a range. The goal is to find the count of Unary numbers existing between [ start, end ].We can check if the number is Unary by following steps: If we take a number 13 then 12 + 32 = 10, then 12 + 02 = 1 So the ultimate sum in this way is 1 so 13 is unary.For ExampleInputstart=1 end=20OutputCount of Unary Numbers in a Range are: 5ExplanationThe numbers are : 1, 7, 10, 12, and 13Inputstart=50 end=100OutputCount of Unary Numbers in a Range are: 7ExplanationThe numbers are − 59, 63, 67, ... Read More

200 Views
We are given a number N as input. Perform two operations on N and identify the count of unique numbers generated in the process. Steps will −Add 1 to numberRemove trailing zeros from the generated number, if anyIf N is 8 then numbers generated will beApplying step 1− 8 → 9 →Applying step 2− 1 → ( removed 0 from 10 )Applying step 1: 2 → 3 → 4 → 5 → 6 → 7 → 8 ( same sequence )Count of unique numbers will be 9.For ExampleInputN=21OutputCount of unique numbers that can be generated from N by adding one ... Read More

264 Views
Given a sorted doubly linked list containing integer values. The goal is to find triplets whose product is equal to the given value x. If input linked list is 3−4−1−2 and x is 6 then count will be 1 (triplet (3, 1, 2) )For ExampleInputlinked list: [ 3−4−13−5−10−10−0 ] x=20OutputCount of triplets in a sorted doubly linked list whose product is equal to a given value x are: 2ExplanationTriplets will be: ( 3, 4, 13 ) and ( 10, 10, 0 )Inputlinked list: [ 4−3−1−5−2−4−2 ] x=8OutputCount of triplets in a sorted doubly linked list whose product is equal to ... Read More

217 Views
Given a sorted doubly linked list containing integer values. The goal is to find triplets whose product is equal to the given value x. If input linked list is 3−4−1−2 and x is 6 then count will be 1 (triplet (3, 1, 2))For ExampleInputlinked list: [ 200−4−16−5−10−10−2 ] x=200OutputCount of triplets in a sorted doubly linked list whose product is equal to a given value x are: 3ExplanationTriplets will be: (4, 5, 10), (4, 5, 10) and (10, 10, 2)Inputlinked list: [ 4−3−1−5−2−4−2] x=12OutputCount of triplets in a sorted doubly linked list whose product is equal to a given value ... Read More

165 Views
Given an array arr[] containing integer elements and an integer num. The goal is to find the average of each element arr[i] and num and print the count of the number of times that average appeared in the original array.If array arr[] is [ 5, 2, 3 ] and num is 2. Averages will be [ 3, 2, 2 ] occurrences in arr[] is [ 1, 1, 1 ]For ExampleInputarr[] = { 1, 6, 4, 3, 6, 4 } num=2Output1 2 1 0 2 1Count of occurrences of the average of array elements with a given number are − 5ExplanationThe ... Read More

6K+ Views
Given a string str, a character and a positive integer N. The string str is repeated indefinitely. The goal is to find the count of occurrences of character in str in first N characters of repetitions.If str is “abac”, character is ch=‘b’ and N is 10.In first 10 characters of “abacabacabacabac…….” b occurs twice.Note − Take str and character ch within the same case.Let us understand with examples.For ExampleInputstr = "TPTTTT" ch = 'T' n = 12OutputCount of occurrences of a character in a repeated string are: 10ExplanationThe number of ‘T’ in str is 5. Length of str is 6. ... Read More

344 Views
The default residual plot can be created by using the model object name in base R but that is not very attractive. To create a residual plot with better looking aesthetics, we can use resid_panel function of ggResidpanel package. It is created in the same way as the residual plot in base R, also it results in all the relevant graph in one window.ExampleConsider the below data frame −Live Demo> x y df dfOutputx y 1 0.48508894 0.217379409 2 0.75113573 -0.657179470 3 -0.13075185 -0.549613217 4 -0.26867557 1.156736294 5 0.40407850 0.640387394 6 -0.23816272 -0.807847198 7 -0.57278583 0.600249694 8 -0.78222676 -0.711133218 9 ... Read More

638 Views
If we have two string vectors, each containing more than two values then it becomes a little difficult to create the combinations for each string value in those two vectors. For this purpose, we can make use of do.call function paste0 and expand.grid as shown in the below examples.ExampleLive Demo> x1 y1 do.call(paste0, expand.grid(x1, y1))Output[1] "AK" "BK" "CK" "DK" "EK" "FK" "GK" "HK" "IK" "JK" "AL" "BL" "CL" "DL" "EL" [16] "FL" "GL" "HL" "IL" "JL" "AM" "BM" "CM" "DM" "EM" "FM" "GM" "HM" "IM" "JM" [31] "AN" "BN" "CN" "DN" "EN" "FN" "GN" "HN" "IN" "JN" "AO" "BO" "CO" ... Read More

7K+ Views
To get the top values in an R data frame, we can use the head function and if we want the values in decreasing order then sort function will be required. Therefore, we need to use the combination of head and sort function to find the top values in decreasing order. For example, if we have a data frame df that contains a column x then we can find top 20 values of x in decreasing order by using head(sort(df$x, decreasing=TRUE), n=20).ExampleConsider the CO2 data frame in base R −Live Demo> str(CO2)OutputClasses ‘nfnGroupedData’, ‘nfGroupedData’, ‘groupedData’ and 'data.frame': 84 obs. of ... Read More

2K+ Views
Sometimes we need the multiplication of two columns and create a new column so that the multiplication can be used further for analysis. For example, to calculate BMI we need mass and height and the height is squared, therefore, we would be needing the square of height. For this purpose, we can either multiply height with height or simply take the square both the ways work. Hence, if only have height column in an R data frame then we can multiply it with itself.ExampleConsider the below data frame −Live Demo> set.seed(957) > x y z df dfOutputx y z 1 ... Read More