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 841 of 3366
349 Views
To solve a problem in which we are given an array containing the size of the boxes. Now we are given a condition that we can fit a smaller box inside a bigger box if the bigger box is at least twice the size of the smaller box. Now we must determine how many visible boxes there are, for example.Input : arr[] = { 1, 3, 4, 5 } Output : 3 Put a box of size 1 in the box of size 3. Input : arr[] = { 4, 2, 1, 8 } Output : 1Approach to Find ... Read More
447 Views
Subarrays are the contiguous part of an array. For example, we consider an array [5, 6, 7, 8], then there are ten non-empty subarrays like (5), (6), (7), (8), (5, 6), (6, 7), (7, 8), (5, 6, 7), (6, 7, 8) and (5, 6, 7, 8).In this guide, we will explain every possible information to find the number of subarrays with odd sums in C++. For finding the number of subarrays with the odd sum, we can use different approaches, so here is a simple example for it −Input : array = {9, 8, 7, 6, 5} Output : 9 ... Read More
336 Views
In this article, we will solve the number of subarrays having sum in a given range using the C++ program. We have an array arr[] of positive integers, and a range {L, R} and we have to calculate the total number of subarrays having sum in the given range form L to R. So here is the simple example for the problem −Input : arr[] = {1, 4, 6}, L = 3, R = 8 Output : 3 The subarrays are {1, 4}, {4}, {6}. Input : arr[] = {2, 3, 5, 8}, L = 4, ... Read More
243 Views
If you have ever used C ++, you must know what subarrays are and how useful they are. As we know that, in C++, we can solve multiple mathematical problems easily. So in this article, we will explain the complete information on how we can find M odd numbers with the help of these subarrays in C++.In this problem, we need to find many subarrays formed with the given array and integer m where each subarray contains exactly m odd numbers. So here is the simple example of this approach −Input : array = { 6, 3, 5, 8, 9 ... Read More
509 Views
In this article, we will solve the problem of finding the number of subarrays whose maximum and minimum elements are the same using C++. Here is the example for the problem −Input : array = { 2, 3, 6, 6, 2, 4, 4, 4 } Output : 12 Explanation : {2}, {3}, {6}, {6}, {2}, {4}, {4}, {4}, {6, 6}, {4, 4}, {4, 4} and { 4, 4, 4 } are the subarrays which can be formed with maximum and minimum element same. Input : array = { 3, 3, 1, 5, 1, 2, 2 } Output : 9 ... Read More
162 Views
In this article, we will explain everything about solving the number of subarrays having the sum of the form k^m, m >= 0 in C++. Given an array arr[] and an integer K, we need to find the number of subarrays having sum in the form of K^m where m is greater than equal to zero, or we can say we need to find the number of subarrays having sum equal to some non-negative power of K.Input: arr[] = { 2, 2, 2, 2 } K = 2 Output: 8 Sub-arrays with below indexes are valid: [1, 1], ... Read More
405 Views
To successfully build a machine learning project, loading data properly is one of the most important as well as challenging tasks. CSV is the most common format for machine learning projects. It is a simple format which is used to store tabular data.Followings are the three most common approaches in Python with the help of which you can load CSV data for machine learning projects −Using Python Standard LibraryTo load CSV data files, Python standard library provides us with a built-in function namely csv module.ExampleIn this example we will be loading CSV data file of iris flower data set −#Importing ... Read More
861 Views
In reinforcement learning methods, a trained agent interacts with a specific environment and takes actions based upon the current state of that environment.The working of reinforcement learning is as follows −First you need to prepare an agent with some specific set of strategies.Now leave the agent to observe the current state of the environment.Based on the agent's observation, select the optimal policy, and perform suitable action.Based on the action taken, the agent will get reward or penalty.Update the set of strategies used in step 1, if needed. Repeat the process from step1-4 until the agent learns and adopts the optimal ... Read More
924 Views
Unsupervised learning methods, (opposite to supervised learning methods) do not require any labels or responses along with the training data. Unsupervised ML algorithms learn patterns and relationships from the given raw data. Although these methods may have lots of uncertainties in the result, we can always obtain some useful information such as all kinds of unknown patterns in the data, and the useful features for categorization.Unsupervised algorithms are called unsupervised because the machine learning model learns from data samples where the output is not known in advance.Let’s make it clearer, suppose we have, Input variables − mBut as opposed to ... Read More
1K+ Views
Supervised learning, one of the most used methods in ML, takes both training data (also called data samples) and its associated output (also called labels or responses) during the training process. The major goal of supervised learning methods is to learn the association between input training data and their labels. For this it performs multiple training data instances.Let’s understand its working with the help of below given example −Suppose we have, Input variables − m andOutput variable − NThe mapping function from the input to output is as follows −𝑁 = 𝑓(𝑚)To learn such mapping function, we need an algorithm ... Read More