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
Programming Articles - Page 690 of 3366
502 Views
numpy.reshape() gives a new shape to an array without changing its data. Its syntax is as follows −numpy.reshape(arr, newshape, order='C')Parametersnumpy.reshape() can accept the following parameters −arr − Input array.shape − endpoint of the sequencenewshape − If an integer, then the result it will be a 1-D array of that length, and one dimension can be -1.order − It defines the order in which the input array elements should be read.If the order is ‘C’, then it reads and writes the elements which are using a C-like index order where the last index changes the fastest and the first axis index ... Read More
216 Views
Suppose we have a string S with N characters. S contains only three types of characters 'A', 'B' or 'C'. We also have another integer K. We have to print S after lowercasing the Kth character in it.So, if the input is like K = 2; S = "AABACC", then the output will be "AaBACC"StepsTo solve this, we will follow these steps −S[K - 1] = S[K - 1] + 32 return SExampleLet us see the following implementation to get better understanding −#include using namespace std; string solve(int K, string S){ S[K - 1] = S[K - ... Read More
161 Views
Suppose we have a string S with lowercase English letters. We must insert exactly one character 'a' in S. After inserting that if we can make S not a palindrome then return that string, otherwise return "impossible".So, if the input is like S = "bpapb", then the output will be "bpaapb"StepsTo solve this, we will follow these steps −if concatenation of S and "a" is not palindrome, then: return S concatenation 'a' otherwise when concatenation of "a" + S is not palindrome, then: return 'a' concatenation S Otherwise return "Impossible"ExampleLet us see the following implementation to get ... Read More
555 Views
numpy.geomspace() returns a set of numbers spaced evenly on a log scale (a geometric progression).Linspace − It is similar to geomspace, but endpoints specified using the log and base.Logspace − It is similar to geomspace, but endpoints specified with arithmetic instead of geometric progression.Syntaxnumpy.goemspace(start, stop, num = 50, endpoint = True/False, dtype = None)ParametersThe above function can accept the following parameters −start − Start of the sequence; default is zero.stop − Endpoint of the sequence.num − Number of elements which are generated between the start and stop sequence.endpoint − It controls whether the stop value is included in the output ... Read More
335 Views
Suppose we have two numbers N and K. We want to distribute N crackers to K users. We have to find the minimum possible difference between the largest number of crackers received by a user and smallest number received by a user.So, if the input is like N = 7; K = 3, then the output will be 1, because when the users receive two, two and three crackers, respectively, the difference between the largest number of crackers received by a user and the smallest number received by a user, is 1.StepsTo solve this, we will follow these steps −if ... Read More
410 Views
numpy.logspace returns a set of numbers spaced evenly on a log scale. Its syntax is as follows −numpy.logspace(start, stop, num = 50, endpoint = True/False, base = 10.0, dtype = None)ParametersThe logspace function can accept the following parameters −start − Start of the sequence; default is zero.stop − Endpoint of the sequence.num − Number of elements to be generated between the start and stop sequence.endpoint − It controls whether the stop value is included in the output array or not. If the endpoint is True, then the stop parameter is included as the last item in the nd.array. If endpoint=false, ... Read More
165 Views
Suppose we have two numbers K and X. Consider Amal has K, 500 rupee notes. We have to check whether the sums up to X rupees or not.So, if the input is like K = 2; X = 900, then the output will be True, because 2*500 = 1000 and it is not less than 900.StepsTo solve this, we will follow these steps −if (500 * k) >= x, then: return true Otherwise return falseExampleLet us see the following implementation to get better understanding −#include using namespace std; bool solve(int k, int x){ if ((500 * k) >= x){ return true; } else{ return false; } } int main(){ int K = 2; int X = 900; cout
2K+ Views
The numpy.linspace function is used to create a set of evenly spaced numbers within a defined interval.Syntaxnumpy.linspace(start, stop, num = 50, endpoint = True/False, retstep = False/True, dtype = None)ParametersThe function can accept the following parameters −start − Start of the sequence; by default, it is considered as zero.stop − Endpoint of the sequence.num − Number of elements to be generated between start and stop.endpoint − It controls whether the stop value is included in the output array or not. If the endpoint is True, then the stop parameter is included as the the last item in the nd.array. If ... Read More
311 Views
Suppose we have two arrays A and B both with N elements. Consider there are N computers and N sockets. The coordinate of ith computer is A[i] and coordinate of ith socket is b[i]. These 2N coordinates are pair-wise distinct. We want to connect each computer with a socket by cables. Each socket can be connected at most one computer. We have to count in how many ways we can minimize the length of cables. If the answer is too large, return result mod 10^9 + 7.So, if the input is like A = [0, 10]; B = [20, 30], ... Read More
242 Views
Suppose we have an array A with 4 elements. There are 4 bags of candies, ith bag contains A[i] amount of candies. We want to give each bags to one of our two friends. We have to check whether we can distribute these bags in such a way that each friend receives the same amount of candies in total?So, if the input is like A = [1, 7, 11, 5], then the output will be True, because we can give the first and the third bag to the first friend, and the second and the fourth bag to the second ... Read More