
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

581 Views
In this problem, we are given an integer value N. Our task is to find Sum of Series 1 + 22 + 333 + 4444 + 55555... upto n terms.Let's take an example to understand the problem, Input : N = 4 Output : 4800Explanation −1 + 22 + 333 + 4444 = 4800 Solution ApproachA simple approach to solve the problem is finding the general term of the series and then finding the sum till n terms. And calculating the sum using formula will reduce the time to O(1).The series is, 1 + 22 + 333 + 4444 + ... Read More

2K+ Views
In this problem, we are given an integer value N. Our task is to find Sum of Series 1 - 2 + 3 - 4 + 5 - 6 + 7 upto n terms.The series is 1 - 2 + 3 - 4 + 5 - 6 + 7 - 8 + 9 - 10...Let's take an example to understand the problem, Input : N = 4 Output : -2Explanation −1 - 2 + 3 - 4 = -2 Solution ApproachA simple approach to solve the problem is finding the general term of the series and then finding the sum ... Read More

153 Views
In this problem, we are given an integer value N. Our task is to find Sum of Series ?3 + ?12 + ... upto n terms.The series is $\sqrt3 + \sqrt12 + \sqrt27 + \sqrt48 + ...$I.e. It is a series of square roots.Let's take an example to understand the problem, Input : N = 3 Output : 10.3922Explanation −$\sqrt3 + \sqrt12 + \sqrt27 = 1.7320 + 3.4641 + 5.1961 = 10.3922$Solution ApproachA simple approach to solve the problem is finding the general term of the series and then finding the sum till n terms. And calculating the sum using ... Read More

400 Views
In this problem, we are given an integer value N. Our task is to find Sum of Series n^2 - (n-1)^2 upto n terms.Let's take an example to understand the problem, Input : N = 3 Output : 6Explanation −[12 - (0)2] + [22 - (1)2] + [32 - (2)2] = 1 - 0 + 4 - 1 + 9 - 2 = 9Solution ApproachA simple approach to solve the problem is finding the general term of the series and then finding the sum till n terms. And calculating the sum using formula will reduce the time to O(1). Also, ... Read More

1K+ Views
In this problem, we are given an integer value N. Our task is to find Sum of Series 1^2 - 2^2 + 3^2 - 4^2 ... upto n terms.Let's take an example to understand the problem, Input : N = 3 Output : 6Explanation −12 - 22 + 32 = 1 - 4 + 9 = 6Solution ApproachA simple approach to solve the problem is using loops. We will loop from 1 to n with iterator i.If i is odd, add (i2) to the sum.If i is even, subtract (i2) to the sum. At last, return the sum of series ... Read More

296 Views
In this problem, we are given two arrays, positive and distinct. Our task is to find the sum of pairs from two arrays with maximum sum.We will find the pair with the maximum sum with one element from each array.Let's take an example to understand the problem, Input : arr1[] = {3, 7, 5}, arr2[] = {8, 2, 4} Output : 15Explanation −Pairs is (7, 8) = 7 + 8 = 15 Solution ApproachA simple approach to solve the problem is using loops. We will use a nested loop and find the sum of all pairs and return the pair ... Read More

859 Views
In this problem, we are given a linked list. Our task is to find the sum of even and odd nodes in a linked list.Let's take an example to understand the problem, Input : linked list : 3 -> 2 -> 5 -> 7 -> 1 -> 9 Output : evenSum = 2 ; oddSum = 25Explanation −evenSum = 2 oddSum = 3 + 5 + 7 + 1 + 9 = 25Solution ApproachA simple approach to solve the problem is traversing the linked list and checking for even or odd values and adding them to their respective sum value.AlgorithmStep ... Read More

1K+ Views
In this problem, we are given a natural number N. Our task is to find the sum of divisors of all the divisors of a natural number.Let's take an example to understand the problem, Input : N = 12 Output : 55Explanation −The divisors of 12 are 1, 2, 3, 4, 6, 12 Sum of divisors = (1) + (1 + 2) + (1 + 3) + (1 + 2 + 4) + (1 + 2 + 3 + 6) + (1 + 2 + 3 + 4 + 6 + 12) = 1 + 3 + 4 + 7 ... Read More

11K+ Views
To find the indices of the maximum value of the elements in an input tensor, we can apply the torch.argmax() function. It returns the indices only, not the element value. If the input tensor has multiple maximal values, then the function will return the index of the first maximal element. We can apply the torch.argmax() function to compute the indices of the maximum values of a tensor across a dimension..Syntaxtorch.argmax(input)StepsWe could use the following steps to find the indices of the maximum values of all elements in the input tensor −Import the required library. In all the following examples, the ... Read More

966 Views
To compute elementwise logical AND of given input tensors we apply torch.logical_and(). It takes two input tensors and computes the logical AND element wise. The zeros in the tensors are treated as False and non-zeros as True. The input tensors may be of any dimension.The torch.logical_or() function computes elementwise logical OR of the given input tensors. It also takes two input tensors and outputs a tensor with True or False. As same in logical AND zeros are treated as False and non-zeros are treated as True.The input tensors may be of any dimension.To compute the elementwise NOT of a given ... Read More