Found 26504 Articles for Server Side Programming

Maximize the subarray sum after multiplying all elements of any subarray with X in C++

Sunidhi Bansal
Updated on 22-Oct-2021 07:42:24

301 Views

We are given with an integer array and an integer variable i.e. ‘X’. The task is to firstly form the subarray from the given array and then multiply all the elements of a subarray with an integer X. At last find out the elements that will contribute the maximum sum.Let us see various input output scenarios for this -In − int arr[] = {2, 4, 1, -5, -2}, X = 3Out  − Maximize the subarray sum after multiplying all elements of any subarray with X are: 21Explanation − we are given with an array and an integer variable as X. Firstly, ... Read More

Python Pandas - Return the count of increments applied on the CustomBusinessDay offset

AmitDiwan
Updated on 22-Oct-2021 07:31:25

112 Views

To return the count of increments applied on the CustomBusinessDay offset, use the CustomBusinessDay.n property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-10-22 03:10:35') Create the CustomBusinessDay Offset −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 4, weekmask = 'Mon Tue Wed Fri')Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) Return the count of increments on the given CustomBusinessDay object −print("The count of increments on the CustomBusinessDay object..", cbdOffset.n)ExampleFollowing is the code −import pandas as pd # Set the timestamp object in Pandas timestamp ... Read More

Python Pandas - Return the rule code applied on the given CustomBusinessDay object

AmitDiwan
Updated on 22-Oct-2021 07:21:28

90 Views

To return the rule code applied on the given CustomBusinessDay object, use the CustomBusinessDay.rule_code property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-10-22 03:10:35') Create the CustomBusinessDay Offset .CustomBusinessDay is the DateOffset subclass representing custom business days excluding holidays −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri')Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) Return the rule code of the frequency applied on the given CustomBusinessDay Offset −print("The rule code of the CustomBusinessDay object..", cbdOffset.rule_code)ExampleFollowing is the code ... Read More

Python Pandas - Check whether the CustomBusinessDay Offset has been normalized or not

AmitDiwan
Updated on 22-Oct-2021 07:08:04

142 Views

To check whether the CustomBusinessDay Offset has been normalized or not, use the CustomBusinessDay.normalize property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-10-22 03:10:35') Create the CustomBusinessDay Offset. CustomBusinessDay is the DateOffset subclass representing custom business days excluding holidays. Weekmask of valid business days. We have normalized the CustomBusinessDay using the "normalize" parameter −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri', normalize=True)Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) Check whether the CustomBusinessDay Offset is normalized or not ... Read More

Python Pandas - Return the name of the frequency applied on the given CustomBusinessDay offset object

AmitDiwan
Updated on 22-Oct-2021 07:05:54

110 Views

To return the name of the frequency applied on the given CustomBusinessDay offset object, use the CustomBusinessDay.name property.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-12-31 08:35:10') Create the CustomBusinessDay Offset. CustomBusinessDay is the DateOffset subclass representing custom business days excluding holidays −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri')Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) Return the name of the frequency applied on the given CustomBusinessDay object −print("The name of the frequency on the CustomBusinessDay object..", cbdOffset.name)ExampleFollowing is ... Read More

Python Pandas - Display the keyword arguments applied on the given CustomBusinessDay object

AmitDiwan
Updated on 22-Oct-2021 07:03:47

98 Views

To display the keyword arguments applied on the given CustomBusinessDay object, use the CustomBusinessDay.kwds property in Pandas.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-12-31 08:35:10') Create the CustomBusinessDay Offset −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri')Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) Display the keyword arguments −print("Keyword arguments on the given CustomBusinessDay Offset...", cbdOffset.kwds)ExampleFollowing is the code −import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-12-31 08:35:10') # Display the ... Read More

Python Pandas - Return frequency applied on the given CustomBusinessDay Offset object as a string

AmitDiwan
Updated on 22-Oct-2021 07:00:36

95 Views

To return frequency applied on the given CustomBusinessDay Offset object as a string, use the CustomBusinessDay.freqstr property.At first, import the required libraries −import pandas as pdSet the timestamp object in Pandas −timestamp = pd.Timestamp('2021-12-31 08:35:10') Create the CustomBusinessDay Offset −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 2, weekmask = 'Mon Tue Wed Fri')Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) Return frequency applied on the given CustomBusinessDay Offset object as a string −print("Frequency applied on the given CustomBusinessDay Offset object...", cbdOffset.freqstr)ExampleFollowing is the code −import pandas as pd # Set the timestamp object in ... Read More

Python Pandas - Create a CustomBusinessDay Offset object

AmitDiwan
Updated on 22-Oct-2021 06:55:52

444 Views

To create a CustomBusinessDay Offset object, use the pd.tseries.offsets.CustomBusinessDay() method in Pandas.At first, import the required libraries −import pandas as pdCreate the CustomBusinessDay Offset. CustomBusinessDay is the DateOffset subclass representing custom business days excluding holidays. Weekmask of valid business days −cbdOffset = pd.tseries.offsets.CustomBusinessDay(n = 5, weekmask = 'Mon Tue Wed Fri') Set the timestamp object in Pandas −timestamp = pd.Timestamp('2021-12-31 08:35:10')Add the offset to the Timestamp and display the Updated Timestamp −print("Updated Timestamp...", timestamp + cbdOffset) ExampleFollowing is the code −import pandas as pd # Set the timestamp object in Pandas timestamp = pd.Timestamp('2021-12-31 08:35:10') # Display the ... Read More

Maximize the sum of array by multiplying prefix of array with -1 in C++

Sunidhi Bansal
Updated on 22-Oct-2021 07:30:50

295 Views

We are given an integer array and the task is to firstly fetch the prefix of an array and then multiply it with -1, secondly calculate the prefix sum of an array and lastly find the maximum sum from the prefix array generated.Prefix array is generated as −First element of prefixArray[0] = first element of an arraySecond element of prefixArray[1] = prefixArray[0] + arr[1]Third element of prefixArray[2] = prefixArray[1] + arr[2]Fourth element of prefixArray[3] = prefixArray[2] + arr[3] …..etc.Let us see various input output scenarios for this -In − int arr[] = {2, 4, 1, 5, 2}Out − Prefix array is: ... Read More

Minimum sum submatrix in a given 2D array in C++

Sunidhi Bansal
Updated on 22-Oct-2021 06:40:12

608 Views

We are given a 2-D array of integer elements forming the matrix. The task is to calculate the count of minimum sum by pulling the submatrix from the matrix so formed.Let us see various input output scenarios for this -In −int matrix[size][size] = { {2, 3, -1, 5}, {-2, 9, -1, 6}, { 5, 6, 9, -9}, { -6, 1, 1, 1} }Out −Minimum sum submatrix in a given 2D array is: -9Explanation −we are given a 2-D array of size 4x4 i.e. 4 rows and 4 columns. Now, we will find out the sub-matrix from the given matrix such ... Read More

Advertisements