Suppose we have an array of n elements. We have to find the maximum number of elements to select from the array, such that the absolute difference between any two of the chosen elements is less than or equal to 1. So if the array is like [2, 2, 3, 4, 5], then the element will be 3, so the sequence with maximum count is 2, 2, 3.The absolute difference of 0 and 1 means, that the number can be of type x and x + 1. So the idea is to store the frequencies of array elements. So if ... Read More
Here we will see how to use the sort() function of C++ STL to sort an array So if the array is like A = [52, 14, 85, 63, 99, 54, 21], then the output will be [14 21 52 54 63 85 99]. To sort we will use the sort() function, that is present in the header file . The code is like below −Example Live Demo#include #include using namespace std; int main() { int arr[] = {52, 14, 85, 63, 99, 54, 21}; int n = sizeof(arr) / sizeof(arr[0]); cout
Suppose we want to make a stack that can store the maximum element in the stack. And we can get it in O(1) time. The constraint is that, it should use O(1) extra space.We can make one user-defined stack, that will store the max value, when one operation is performed, like pop or peek, then the max will be returned. For peek operation, return the maximum of stack top and the max element, for pop operation, when the top element is larger, then print it and update max as 2*max – top_element. otherwise return top_element. For push operation update the ... Read More
Use jQuery hasAttribute() method to see if there is an attribute for an element.ExampleYou can try to run the following code to learn how to use hasAttribute() method:Live Demo $(document).ready(function(){ $('button').on('click', function() { if (this.hasAttribute("style")) { alert('True') } else { alert('False') } }) }); Check for attribute in the button element Button Button 2
You can go for using either NULLIF or COALESCE function to serve your requirement.NULLIF (expression, expression"): This function will return the same type whatever is specified as the first expression.Basically, NULLIF returnsThe first expression if the two expressions are not equal.NULL of type of first expressions if the expressions are equalThe other function available is COALESCE which basically checks if the first Value provided is NULL then it will return the second value.Examplec = COALESCE(b , a)If b is null then the function will return an otherwise b. So If you need to put a null check and use some ... Read More
In this section we will see how to create and use complex numbers in C++. We can create complex number class in C++, that can hold the real and imaginary part of the complex number as member elements. There will be some member functions that are used to handle this class.In this example we are creating one complex type class, a function to display the complex number into correct format. Two additional methods to add and subtract two complex numbers etc.Example Live Demo#include using namespace std; class complex{ int real, img; public: complex(){ ... Read More
You can opt for using regular expressions to remove the duplicate numbers from column c or any other intended column.ExampleSELECT REPLACE_REGEXPR ('([A-Za-z0-9])\1+' in 'BB11222343CC' WITH '\1' OCCURRENCE ALL) FROM OutputB12343C
You need to perform the below actions when you are stopping the JCO server instanceDelete all the references of your server from ServerDataEventListener instance. If you need to use the reference, then you can use registered ServerDataProvider object to fetch reference of ServerDataEventListener instance.Delete all the references of your destination from DestinationDataEventListener instance. If you need to use the reference, then you can use registered DestinationDataProvider object to fetch the DestinationDataEventListener instance.
The SAPUI5 library files are a part of Eclipse SAPUI5 plug-in.If you are running the app by using the Web App preview on the startup page ( Go to Run As -> select “Web APP Preview”), then eclipse starts a local HTTP server for development which serves at “/resources” the library.Till the preview window is open, you can go ahead and use the URL in any browser of your choice to debug the application.
Here we will see some good tricks of C++ programming language that can help us in different area. Like if we want to participate in some competitive programming events, then these tricks will help us to reduce the time for writing codes. Let us see some of these examples one by one.Checking whether a number is odd or even without using % operator. This trick is simple. We can perform bitwise AND operation with the number and 1. If the result is non-zero then this is odd, otherwise this is even. The logic is too simple. All odd numbers have ... Read More
 Data Structure
 Networking
 RDBMS
 Operating System
 Java
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP