Options are "derivative investments", meaning the price movements of the investments are based on the price movements of another financial product. The financial product from which the derivative is obtained is called the "underlying."Call and Put OptionsOptions are contracts that provide the buyer the right to buy or sell an underlying asset, at a predetermined price and before a specific date.A call option is bought by a trader if the investor expects the price of the underlying to rise within a certain time frame.A put option is bought by a trader if he/she expects the price of the underlying to ... Read More
Suppose we have a string s and another array of integers called cost where cost[i] represents the cost of deleting the ith character in s. We have to find the minimum cost of deletions such that there are no two same letters next to each other. We have to keep in mind that that we will delete the chosen characters at the same time. So after deleting a character, the costs of deleting other characters will not change.So, if the input is like s = "pptpp", cost = [2, 3, 4, 5, 2], then the output will be 4 because ... Read More
Suppose we have two arrays nums1 and nums2, we have to find of triplets formed (type 1 and type 2) following these two rules −Triplet (i, j, k) if nums1[i]^2 = nums2[j] * nums2[k] where [0
What is a Strike Price?In the case of an option contract, the "strike price" is the predetermined and agreed-upon price at which a specific security may be bought (by the call option holder) or sold (by the put option holder) until or upon the expiration of the contract. The term "strike price" is also termed as "exercise price."Options are derivatives that offer their buyers a right, or an option—but not an obligation—to buy or sell a security, such as a stock at a specific price (or the strike price) until or on a certain date (the expiration date).Buying or selling ... Read More
Suppose we have an array called arr, we have to remove a subarray of arr such that the remaining elements in arr are in non-decreasing order. We have to find the length of the shortest subarray to remove.So, if the input is like arr = [10, 20, 30, 100, 40, 20, 30, 50], then the output will be 3 because we can remove [100, 40, 20] which is smallest subarray of length 3, and by removing these all are in non-decreasing order [10, 20, 30, 30, 50].To solve this, we will follow these steps:n := size of arrarr := insert ... Read More
Suppose we have a binary string s we can split s into 3 non-empty strings s1, s2, s3 such that (s1 concatenate s2 concatenate s3 = s). We have to find the number of ways s can be split such that the number of characters '1' is the same in s1, s2, and s3. The answer may be very large so return answer mod 10^9+7.So, if the input is like s = "11101011", then the output will be 2 because we can split them like "11 | 1010 | 11" and "11 | 101 | 011".To solve this, we will ... Read More
Suppose we have an array called nums, we have to find the maximum length of a subarray where the product of all its elements is positive. We have to find the maximum length of a subarray with positive product.So, if the input is like nums = [2, -2, -4, 5, -3], then the output will be 4 because first four elements are forming a subarray whose product is positive.To solve this, we will follow these steps :Define a function util() . This will take s, eneg := 0ns := -1, ne := -1for i in range s to e, doif ... Read More
We will use plot.density() to density plot on a Dataset in the form of a csv file. Let’s say the following is our dataset − Cricketers2.csvAt first, import the required libraries −import pandas as pd import matplotlib.pyplot as pltLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers2.csv") Plotting the density plot. Attribute considered is "Age" −dataFrame.Age.plot.density(color='green')ExampleFollowing is the complete code −import pandas as pd import matplotlib.pyplot as plt # Load data from a CSV file into a Pandas DataFrame dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers2.csv") # plotting the density plot # attribute considered is "Age" dataFrame.Age.plot.density(color='green') plt.title('Density ... Read More
Violin Plot in Seaborn is used to draw a combination of boxplot and kernel density estimate. The seaborn.violinplot() is used for this. We will plotti violin plot with the columns grouped by a categorical variable.Let’s say the following is our dataset in the form of a CSV file − Cricketers.csvAt first, import the required libraries −import seaborn as sb import pandas as pd import matplotlib.pyplot as pltLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers.csv") Plotting violin plot with Role and Age grouped by a categorical variable −sb.violinplot(x = 'Role', y = "Age", data = dataFrame)ExampleFollowing ... Read More
Bar Plot in Seaborn is used to show point estimates and confidence intervals as rectangular bars. The seaborn.barplot() is used. Set caps to the error bars using the capsize parameter.Let’s say the following is our dataset in the form of a CSV file − Cricketers2.csvAt first, import the required libraries −import seaborn as sb import pandas as pd import matplotlib.pyplot as pltLoad data from a CSV file into a Pandas DataFrame −dataFrame = pd.read_csv("C:\Users\amit_\Desktop\Cricketers2.csv") Set caps to the error bars using the capsize parameter −sb.barplot(x=dataFrame["Role"], y=dataFrame["Matches"], capsize=.3)ExampleFollowing is the code −import seaborn as sb import pandas as pd import matplotlib.pyplot ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP