# Part 2 : Discovering Options

This is a continuation of my story from part1.

After learning about futures contract. I had an insane amount of success. I grew to over 2.5 Laksh in 3 weeks. Learnt all kinds of technical analysis. And they were all working for me. This was the month of January 2021. And if anyone takes the chart for that month on NIFTY. There have only been new highs every day. Naturally, I was bound to only succeed. I was carefully selecting stocks that would give me good movement. If I get into the detail of how, I will have to take…

# Part 1 : The beginning

This is a continuation of the story I wrote here.

After realising that the stocks given to me by my employer has doubled. I decided that I should also start investing some money on stocks. I wanted to invest in the stock exchanges of USA. Since I already saw the success of the companies being traded there. I didn’t really think about investing in Indian companies. So it was an option I never really thought about(just saying I am not against investing in Indian companies).

Very few people know that Indians can invest in US based company stocks legally. I…

# How I went from an Engineer to Writing Options

It’s been a long time since I last wrote a story on my medium page. This post tells you my story of how I started writing options on the stock market.

After graduating with my Computer Science(CS) degree from NIT-Trichy I got a full time job at PayPal in 2019. From the time I joined college till graduation I was very excited about my course and kept exploring all sorts of fields in CS. I finally found that I enjoyed Data Structures and Algorithms(DSA) way more than rest of the subjects that the course offered. …

# Bargain

Given a number A. Remove some k length consecutive digits (substring) d(i),d(i+1),d(i+2)…..d(i+k) concatinate the rest of the digits. Find some of all such concatinated numbers after removing all possible non empty substrings less than n

## Example

1021

All possible substring 1,10,102,021,21,1,02. 1021 is a substring but its length is the whole initial number so omit it.

The concatinated digits will then be 021,21,1,1,10,102,11. Now what we need is the sum 021+21+1+1+1+102+11.

## Constraints

number of digits ≤ 10⁵

## Solution

Let us first remove all the left substrings, meaning all substring starting at index 1 (substring[1 to i]) for i from 1…

# Sage’s Birthday

Given an array A let’s define minima as all an element that is smaller than both its neighbours a[i] < a[i+1] and a[i] < a[i-1].

## Problem Statement

Given an Array A find an ordering that gives maximum minima’s.

## Solution

The maximum number of minimas possible is n/2 — (n%2==0) call this M

Since we are looking at minimas it is optimal to sort the array and pick the first M elements and try to make them the minimas.

A1, A2, A3, A4, A5, A6, …….

Now what would be the ideal position to place these minimas.

A1 > A2…

# Pokémon Army

Given an array find the subsequence that gives maximum alternate sum.

Alternate sum of A = [5,4,3,2,1] = 5–4+3–2+1

Example :
A = [3,1,5,9,10,4,6,8,7,2] the subsequence that gives maximum would be [3,1,10,4,8]

## Solution

Brute force would be to consider adding +/- sign to each index or not have it at all. Therefore each element has 3 possibilities. Which makes the time total solutions to be 3*3*3*….. for an array of size n therefore it is 3^n

You can implement this by simple recursion and further speed it up a little bit by memoisation.

lets call dp(i,+) as the…

# Next Permuatation: Leetcode

Given a vector of numbers. Find the next permutation.

This is a frequently asked interview question. Most people who have read the solution once would find this quite straight forward to answer when asked in an interview coding round or face to face one.

But those who are interested in figuring out the solution by yourself. Read on!

TLDR; This is an explanation of how to find the solution to next permuation from examples.

Let’s take an example 12568. It’s always good to take relatively large sequence. Since taking a small example like 123 won’t get you far since there…

Codeforces 231-C

# Problem Statement

find problem statement here.

codeforces 246-D

# Problem statement

You’ve got an undirected graph, consisting of n vertices and m edges. We will consider the graph’s vertices numbered with integers from 1 to n. Each vertex of the graph has a color. The color of the i-th vertex is an integer c_i.

Let’s consider all vertices of the graph, that are painted some color k. Let’s denote a set of such as V(k). …

# Educational Round 66

Problem D : Array Splitting

# Problem Statement

You are given an array a_1,a_2,…,a_n and an integer k.

You are asked to divide this array into k non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let f(i) be the index of subarray the i-th element belongs to. Subarrays are numbered from left to right and from 1 to k.

Let the cost of division be equal to ∑(a_if(i)).

For example, if a=[1,−2,−3,4,−5,6,−7] and we divide it into 3 subbarays in the following way: [1,−2,−3],[4,−5],[6,−7], then the cost of division is equal to 1⋅1−2⋅1−3⋅1+4⋅2−5⋅2+6⋅3−7⋅3=−9.

Calculate the maximum…

## dragonzurfer

STAY HUNGRY.STAY FOOLISH.

Get the Medium app