Articles on Trending Technologies

Technical articles with clear explanations and examples

Upper bound and Lower bound for non increasing vector in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 14-Aug-2020 4K+ Views

In this article we are going to discuss the vector::upper_bound() and vector::lower_bound() for an array sorted in non-increasing order in C++ STL.Vectors are similar to the dynamic arrays; they have the ability to modify its size itself whenever a value is inserted into or removed from the container where we are storing the value.In a Vector, lower bound returns an iterator pointing to the first element in the range that does not compare the given value. Upper Bound returns an iterator pointing element in the range that smaller than given value.Input 30 30 30 20 20 20 10 10Output Lower bound of ...

Read More

Split the sentence into words in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 14-Aug-2020 2K+ Views

Given is the task to split the sentence into words. In this, we will separate all the words present in sentence.Input I am a good boyOutput I am a good boyIn the above example we will print the single word in single line.Example#include #include #include Using namespace std; void split( string st){    String word = “ “;    for ( char s : st){       If (s== ‘ ‘){          Cout

Read More

Maximum and Minimum element of a linked list which is divisible by a given number k in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 14-Aug-2020 333 Views

A linked list is a linear data structure in which elements are linked via pointers. Each element or node of a linked list has a data part and link, or we can say pointer to the next element in sequence. The elements can take noncontiguous locations in memory.We are given a singly linked list in which there is a data part and link to the next element. The other input is a number K. Task is to find the Maximum and Minimum element of a linked list which is divisible by the number K. The linear linked list can only ...

Read More

Maximum adjacent difference in an array in its sorted form in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 14-Aug-2020 1K+ Views

We are given with an array. The array need not be sorted. The task is to find the maximum difference between adjacent elements of that array in its sorted form. So the first thing is to sort the array in increasing or decreasing order. Then we will iterate the array and calculate the adjacent difference of Arr[i+1]-Arr[i]. Then for each iteration we will compare this difference with the one which is found maximum so far.Input − Arr[] = [ 1, 5, 10, 2, 7 ]Output − Maximum adjacent difference in array in its sorted form is 3.Explanation − Sorted Arr[] ...

Read More

Maximize the sum of X+Y elements by picking X and Y elements from 1st and 2nd array in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 14-Aug-2020 392 Views

For the given two arrays each of size N, the task is to find the maximum sum by choosing X elements from array 1 and Y elements from array 2.Let’s now understand what we have to do using an example −Input arr1 = {1, 2, 3, 4, 5} ; X=2 arr2 = {1, 3, 5, 2, 7}; Y=3Output Maximum sum here is : 24Explanation − We are selecting 2 number(s) from arr1 and 3 from arr2. Largest 2 of arr1 are 4, 5 and largest 3 of arr2 are 3, 5, 7. Total sum of these 5 elements is 24 which is ...

Read More

Maximize the given number by replacing a segment of digits with the alternate digits given in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 14-Aug-2020 438 Views

Given the task is to maximize a given number with ‘N’ number of digits by replacing its digit using another array that contains 10 digits as an alternative for all single-digit numbers 0 to 9, The given condition is that only a consecutive segment of numbers can be replaced and only once.Input N=1234, arr[]={3 ,0 ,1 ,5 ,7 ,7 ,8 ,2 ,9 ,4}Output 1257Explanation The number 3 can be replaced with its alternative 5= arr[3]The number 4 can be replaced with its alternative 7= arr[4]Input N=5183, arr[]={3 ,0 ,1 ,5 ,7 ,7 ,8 ,2 ,9 ,4}Output 7183Approach used in the below program as followsIn function ...

Read More

Maximize the profit by selling at-most M products in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 14-Aug-2020 600 Views

Given the task is to calculate the maximum profit that can be made by selling at-most ‘M’ products.The total number of products are ‘N’ and the cost price and the selling price of each product is given in the lists CP[] and SP[] respectively.Input N=6, M=4 CP[]={1, 9, 5, 8, 2, 11} SP[]={1, 15, 10, 16, 5, 20}Output 28Explanation − The profit obtained from selling all the products are 0, 6, 5, 8, 3, 9 respectively.So, in order to make maximum profit by selling only 4 products, the products with the highest profit need to be chosen, that is, product number 2, ...

Read More

What are liabilities in accounting?

Mandalika
Mandalika
Updated on 14-Aug-2020 396 Views

According to International Financial Reporting standards (IFRS), Liabilities are present obligations of the enterprises arising from past events, the settlement of which is expected to result in an outflow from the enterprises of resources embodying economic benefits.In simple words, it is amount owned by the company to the creditors.Classification of liabilities is as follows −Current liabilities − Payment period is less than one year. It is also called as short term liability.Examples − Accounts payable, interest payable, income tax payables, bills payable, bank account overdrafts, accrued expenses, short term loans.Non – current liabilities − Payment period is more than one ...

Read More

What are assets in accounts?

Mandalika
Mandalika
Updated on 14-Aug-2020 546 Views

An asset is a resource which has an economic value which can generate future cash flows. It is owned or controlled by individuals, corporation or a government. Asset can be a property, inventory, trademarks or patents.Based on its liquidity, assets are recorded in the balance sheet in descending order. More the asset is liquid takes more time to convert into cash.Classification of assetsThe assets are classified as follows −ExamplesThe examples of assets as per convertibility are as follows −Currents assets − Cash, cash equivalents, short term deposits, stock, office supplies, marketable securities etc.Non- current assets − Land, building, equipment, machinery, ...

Read More

Explain the difference between accrual base accounting vs cash based accounting.

Mandalika
Mandalika
Updated on 14-Aug-2020 324 Views

The main difference between accrual base accounting and cash base accounting is as follows −Cash based accountingAccrual based accountingIt is a single entry accounting.Only cash transactions are recognised.Doesn’t recognise account receivables or accounts payable.Useful for small companies.Easy to understand.Focus on liquidity.Not recognised by companies act.Not a holistic approach.Not more accurate.Matching concept can’t be applicable.Low degree of accuracy.Shows lower income in income statement.Doesn’t meet GAAP requirements.Can mislead financial status.It is double entry accounting.Revenue and expenses are recorded irrespective of cash.Commonly used method.Complex and difficult to understand.Recognised by companies act.Focus on revenue, expenses, profit and loss.It has holistic approach.More accurate method.Match concept ...

Read More
Showing 51531–51540 of 61,299 articles
Advertisements