
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

547 Views
To extract string vector elements up to a fixed number of characters in R, we can use substring function of base R.For Example, if we have a vector of strings say X that contains 100 string values and we want to find the first five character of each value then we can use the command as given below −substring(X,1,5)Example 1Following snippet creates a sample data frame −x1
How to display X-axis tick marks as minimum and maximum only without their values using plotly in R?

492 Views
To display X-axis tick marks as minimum and maximum only without their values using plotly, we can use layout function of plot_ly package where we can pass the values for minimum and maximum using xaxis argument and the text using ticktext argument as shown in the below example.ExampleFollowing snippet creates a sample data frame −x

1K+ Views
We are given with a string ‘str’ of any given length. The task is to rearrange the characters in such a manner that the output will be a palindrome string without adding or removing a character from the given input string. Palindrome string is the one in which the characters are arranged in such a manner that they pronounce the same from start and last.Let us see various input output scenarios for this −Input − string str = "itnin"Output − Rearrangement of characters to form palindrome if possible is: nitinExplanation − We are given a string type variable let’s say, str. Now we ... Read More

1K+ Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that when the lowest element in an array is odd then elements of an array will be rearranged in odd first and even second manner. When the lowest element in an array is even then elements of an array will be rearranged in even first and odd second manner and if the number of even/odd elements is more than the number of odd/even elements then it will place the ... Read More

749 Views
If we have a string vector that contains more than one element then there might exists some common values in all the elements. If we want to find those values then intersect function can be used along strsplit function and Reduce function.Check out the below Examples to understand how it can be done.Example 1>x1=c("Data science is an interdisciplinary field that uses scientific methods, processes, algorithms and systems to extract knowledge and insights from structured and unstructured data, and apply knowledge and actionable insights from data across a broad range of application domains.", "Data science is the domain of study that ... Read More

162 Views
We are given integer variables, let's say, N and K. The task is to firstly calculate the permutation of N and then rearrange the permutation in such a manner that it will be K distance from every element.Let us see various input output scenarios for this −Input − int n = 20, int k = 2Output − Rearrangement of first N numbers to make them at K distance is: 3 4 1 2 7 8 5 6 11 12 9 10 15 16 13 14 19 20 17 18.Explanation − we are given integer variables ‘N’ i.e. 20 and ‘K’ i.e. 2. Now ... Read More

368 Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that all the elements of an array are sorted using the inbuilt sort function of C++ STL as well as using recursive technique of coding and printing the result.Let us see various input output scenarios for this −Input − int arr[] = {4, 2, -1, -1, 6, -3, 0}Output − Rearrangement of positive and negative numbers with constant extra space is: -3 -1 -1 0 6 2 4.Explanation − we are given ... Read More

1K+ Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that all the elements of an array are sorted using the inbuilt sort function of C++ STL as well as using recursive technique of coding and printing the result.Let us see various input output scenarios for this −Input − int arr[] = {4, 2, -1, -1, 6, -3, 0}Output − Rearrangement of positive and negative numbers using inbuilt sort function is: -3 -1 -1 0 2 4 6.Explanation − we are given ... Read More

401 Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that all positive and negative numbers should be at alternate positions and if there are extra positive or negative elements then they will be placed in the end of an array.Let us see various input output scenarios for this −Input − int arr[] = {4, 2, -1, -1, 6, -3}Output − Rearrangement of positive and negative numbers in O(n) time and O(1) extra space is: 2 - 1 6 -1 4 ... Read More

352 Views
To find the sum of values based on two groups if missing values are present, we can use group_by and summarise function of dplyr package.For example, if we have a data frame called df that contains a numerical column say Num and two grouping columns say Grp1 and Grp2 then, the sum of values in Num based on Grp1 and Grp2 if missing values are present in df can be found by using the below mentioned command −df%>%group_by(Grp1, Grp2)%>%summarise(Sum=sum(Num, na.rm=TRUE))Example 1Following snippet creates a sample data frame −grp1Read More