Found 26504 Articles for Server Side Programming

Return evenly spaced numbers on a log scale and do not set the endpoint in Numpy

AmitDiwan
Updated on 16-Feb-2022 09:55:54

181 Views

To return evenly spaced numbers on a log scale, use the numpy.logspace() method in Python Numpy. The 1st parameter is the "start" i.e. the start of the sequence. The 2nd parameter is the "end" i.e. the end of the sequence. The 3rd parameter is the "num" i.e. the number of samples to generate. Default is 50. The 4th parameter is the "endpoint". If True, stop is the last sample. Otherwise, it is not included. Default is True.In linear space, the sequence starts at base ** start (base to the power of start) and ends with base ** stop (see endpoint ... Read More

Return evenly spaced numbers on a log scale and set the number of samples to generate in Numpy

AmitDiwan
Updated on 16-Feb-2022 09:52:04

1K+ Views

To return evenly spaced numbers on a log scale, use the numpy.logspace() method in Python Numpy. The 1st parameter is the "start" i.e. the start of the sequence. The 2nd parameter is the " end" i.e. the end of the sequence. The 3rd parameter is the num i.e. the number of samples to generate. Default is 50.In linear space, the sequence starts at base ** start (base to the power of start) and ends with base ** stop (see endpoint below). The start is the base ** start is the starting value of the sequence. The stop is the base ... Read More

Find the smallest after deleting given elements using C++

sudhir sharma
Updated on 14-Feb-2022 09:21:12

171 Views

In this problem, we are given two arrays arr[] and del[]. Our task is to find the smallest after deleting given elements.We will be deleting values from the array arr[] that are present in del[]. And then print the smallest value after deletion.Let’s take an example to understand the problem, Input arr[] = {2, 5, 6, 9, 1} del[] = {1, 5, 9}Output 2Solution ApproachA simple solution to the problem is using hashing. We will insert all the values of del[] array in the hash table. Then we will traverse the array arr[] and check if the values in the ... Read More

Find the slope of the given number using C++

sudhir sharma
Updated on 14-Feb-2022 09:16:48

410 Views

In this problem, we are given a number N. Our task is to find the slope of the given number.Slope of a number is the total number of maxima and minima digits in the number.Maxima digit is the digit whose both neighbours (previous and next) are smaller.Maxima digit is the digit whose both neighbours (previous and next) are greater.Let’s take an example to understand the problem, Input N = 9594459Output 2Solution ApproachA simple solution to the problem is by traversing the number digit by digit from excluding the first and last one (the don’t count form maxima or minima). Now, ... Read More

Minimum Fibonacci terms with sum equal to K in C++

sudhir sharma
Updated on 14-Feb-2022 09:13:05

286 Views

In this problem, we are given a number K. Our task is to find the Minimum Fibonacci terms with sum equal to K.Fibonacci Series generates subsequent numbers by adding two previous numbers. The Fibonacci series starts from two numbers − F0 & F1. The initial values of F0 & F1 can be taken 0, 1 or 1, 1 respectively.Fibonacci Series is 0 1 1 2 3 5 8 13Let’s take an example to understand the problem, InputK = 5Output2ExplanationThe sum 5 can be made using 3 and 2.Solution ApproachBy using Fibonacci numbers we can get the sum as any number ... Read More

Find the number of elements greater than k in a sorted array using C++

Ravi Ranjan
Updated on 10-Jun-2025 17:46:06

1K+ Views

In this problem, we are given an array arr[] consisting of N sorted integer values and an integer k. Our task is to Find the number of elements greater than k in a sorted array. Example Here are some examples of counting the array elements greater than the given target element: Input: arr = {6, 12, 16, 23, 32, 45, 48, 50} target = 20 Output: 5 Input: arr = {6, 12, 15, 20, 32, 45, 48, 50} target = 20 Output: 4 Finding number of elements greater than k in a sorted arrayHere is a list of ... Read More

Maximum occurred integer in n ranges using C++

sudhir sharma
Updated on 14-Feb-2022 07:59:13

538 Views

In this problem, we are given N ranges. Our task is to maximum occurred integer in n ranges.For the starting and ending value of all ranges. We need to find the value which occurs the most.Let’s take an example to understand the problem, Input S1 = 1, E1 = 3 S2 = 2, E2 = 6 S3 = 3, E3 = 4Output 2Solution ApproachA simple approach t o solve the problem is by using hashing, we will use a hash table to count all members and their count. We will traverse all ranges and store count in the hash table, ... Read More

Find the Nth term of the series 14, 28, 20, 40,….. using C++

sudhir sharma
Updated on 14-Feb-2022 07:52:06

342 Views

In this problem, we are given an integer value N.Our task is to find the nth term of the series −14, 28, 20, 40, 32, 64, 56, 112….Let’s take an example to understand the problem, InputN = 6Output64Solution ApproachTo find the Nth term of the series we need to find the general term of the series. For which we need to observe the series closely. I can see two different ways to solve the series.Method 1The series is a mixture of two different series at even and odd positions.At odd positions − 14, 20, 32, 56, ….T1 = 14 T3 ... Read More

C++ program to find Nth Non Fibonacci Number

sudhir sharma
Updated on 14-Feb-2022 07:43:34

946 Views

In this problem, we are given an integer value N. Our task is to use a C + + program to find the Nth Non Fibonacci Number.Fibonacci Series generates subsequent number by adding two previous numbers. The Fibonacci series starts from two numbers − F0 & F1. The initial values of F0 & F1 can be taken 0, 1 or 1, 1 respectively.Let’s take an example to understand the problem, Input N = 5Output 10Solution ApproachA simple solution to the problem is to find the Fibonacci numbers and then print the first n numbers which are not present in the ... Read More

Find the row with maximum number of 1s using C++

sudhir sharma
Updated on 14-Feb-2022 07:39:08

296 Views

In this problem, we are given a binary matrix where elements of each row are sorted. Our task is to find the row with maximum number of 1s.Let’s take an example to understand the problem, Inputmat[][] = {{ 0 1 1 1}    {1 1 1 1}    {0 0 0 1}    {0 0 1 1}}Output1ExplanationThe count of 1’s in each row of the matrix : Row 0 : 3 Row 1 : 4 Row 2 : 1 Row 3 : 2Solution ApproachA simple solution to the problem is by finding the row with the smallest index of the ... Read More

Advertisements