Articles on Trending Technologies

Technical articles with clear explanations and examples

What is $(window).load() method in jQuery?

David Meador
David Meador
Updated on 11-Mar-2026 5K+ Views

The code which gets included inside $( window ).on( "load", function() { ... }) runs only once the entire page is ready (not only DOM).Note: The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0.ExampleYou can try to run the following code to learn how to use $(window).load() method in jQuery − $(document).ready(function(){    $("img").load(function(){      alert("Image successfully loaded.");    }); }); Note: The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0.

Read More

How to check if a matrix is invertible or not in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

If the matrix is singular then it is not invertible and if it is non−singular then it is invertible. Therefore, we can check if a matrix is singular or not. We can use is.singular.matrix function of matrixcalc for this purpose. For example, if we have a matrix called M then to check whether it is invertible or not, we can use is.singular.matrix(M).Example1Loading matrixcalc package and creating a matrix −library(matrixcalc) M1

Read More

How to create a vector with all dates in a particular year in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

We know that some years are leap years and some are normal years. The leap years have 366 days and the normal years have 365 days. To create a vector with all dates in a particular year we can use first date and the last date of the year by reading them with as.Date and creating a sequence with seq function. Check out the below examples to understand how it is done.Example1Creating a vector with dates in year 2020 −seq(as.Date("2020-01-01"), as.Date("2020-12-31"), by="1 day")Output[1] "2020−01−01" "2020−01−02" "2020−01−03" "2020−01−04" "2020−01−05" [6] "2020−01−06" "2020−01−07" "2020−01−08" "2020−01−09" "2020−01−10" [11] "2020−01−11" "2020−01−12" "2020−01−13" "2020−01−14" "2020−01−15" ...

Read More

How to print a large number of values in R without index?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 1K+ Views

Whenever we print any vector then the left-hand side of the R window shows indexing, even if we have one value in the vector the index will be there. For example, if we print a vector that has value equal to 2 then the print output will be [1] 2, here [1] represents the index. If we want to print the vector without index then cat function can be used as shown in the below examples.Example1x1

Read More

Maximum Sum Increasing Subsequence using DP in C++ program

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 275 Views

In this problem, we are given an array arr[] of size n. Our task is to create a program to find the maximum Sum Increasing Subsequence using DP in C++.Problem Description − To find the maximum sum increasing subsequence, we will be creating a subsequence in which the next element is greater than the current element.Let’s take an example to understand the problem, Inputarr[] = {4, 2, 3, 6, 5, 9}Output20ExplanationIncreasing subsequence with maximum sum: {2, 3, 6, 9} = 2 + 3 + 6 + 9 = 20Solution ApproachTo solve the problem using a dynamic Program Approach. We will ...

Read More

Find number of subarrays with even sum in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 422 Views

In this problem, we are given an array arr[] consisting of N elements. Our task is to find the subarray with even sum.Let’s take an example to understand the problem,Inputarr[] = {2, 1, 3, 4, 2, 5}Output28ExplanationThe subarrays are −{2}, {4}, {2}, {2, 4}, {2, 2}, {1, 3}, {1, 5}, {3, 5}, {4, 2}, {2, 1, 3}, {2, 1, 5}, {2, 3, 5}, {2, 4, 2}, {1, 3, 4}, {1, 3, 2}, {1, 4, 5}, {1, 2, 5}, {3, 4, 5}, {3, 2, 5}, {2, 1, 3, 4}, {2, 1, 3, 2}, {2, 3, 4, 5}, {2, 3, 2, 5}, {2, 4, 2, 5}, {1, 3, 4, 2}, {1, 4, 2, 5}, {3, 4, 2, 5}, {2, 1, 3, 4, 2}, {2, 1, 3, 4, 2, 5}Solution ApproachA simple solution to the problem is using the direct method which is by calculating all subarray and their sums. And the increase count for the subarray with even sum. And at last return count.Program to illustrate the working of our solution,Example#include using namespace std; int countEvenSumSubArray(int arr[], int n){    int evenSumCount = 0, sum = 0;    for (int i=0; i

Read More

How to change the repeated row names and column names to a sequence in a matrix in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 552 Views

To change the repeated row names and column names to a sequence, we first need to read those names in a vector then set them to row names and column names with make.unique function. For example, if a matrix has row names defined as A, B, A, B, A then it can be converted into A, B, A.1, B.1, A.2.Example1M1

Read More

What is the difference between creating a matrix by using matrix function or as.matrix function in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 308 Views

The difference between as.matrix and matrix function is that nrow argument or ncol argument are not helpful with as.matrix function but with matrix function we can use them. Therefore, we can actual define a matrix with matrix function but if we have a data frame or data table then it can be converted to matrix by using as.matrix function.Examples of creating matrix with as.matrix and matrix functionExample1M

Read More

Find maximum possible stolen value from houses in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 773 Views

In this problem, we are given n houses with some values in them. Our task is to Find the maximum possible stolen value from houses.Problem Description − We have an array houses[] that consist of the values that are in each house. A thief robs the houses but he cannot steal from two adjacent houses as neighbours know about the theft. We need to find the maximum possible value that can be stolen by the thief from the house without getting caught.Let’s take an example to understand the problem, Inputhouses[] = {5, 2, 1, 6, 7, 9, 4, 3}Output23ExplanationThe max ...

Read More

Find maximum value of Sum( i*arr[i]) with only rotations on given array allowed in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 219 Views

In this problem, we are given an array arr[] consisting of n elements. We need to Find maximum value of Sum( i*arr[i]) with only rotations on a given array allowed. For find the maximum sum of (i*arr[i]), we can perform any number of rotations.Let’s take an example to understand the problem, Inputarr[] = {4, 1, 3, 7, 2}Output43ExplanationWe will rotate the array once to get the maximum value, After rotation array will be {2, 4, 1, 3, 7}Sum = 0*2 + 1*4 + 2*1 + 3*3 + 4*7 = 0 + 4 + 2 + 9 + 28 = 43Solution ...

Read More
Showing 1–10 of 61,248 articles
« Prev 1 2 3 4 5 6125 Next »
Advertisements