Tuesday, August 31, 2021

Leetcode 239. Sliding Window Maximum | My discussion post

Aug. 31, 2021

Here is the link. 

C# | Deque | LinkedList class | LinkedListNode class | Descending order | Aug 2021

August 31, 2021
Introduction
I had a phone screen to work on LRU algorithm in 2020, and I chose to use C# class LinkedList. With 10 years experience, I could not explain what is return type of LinkedList First API. It is LinkedListNode. I could not write working code and ran it in the phone screen. Lessons learned, I like to write down and share with others.

Case study | How to solve it by hand? | Slide window
Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
Output: [3,3,5,5,6,7]
First visit, element value at index = 0, value = 1, which is current window's maximum value's index, put into C# LinkedList, [0]
Next visit, index = 1, value = 3, so argue that first element in the window will never be the maximum value, since 1< 3, remove 0 from LinkedList, call API RemoveFirst.
LinkedList - [1]
Next visit, index = 2, value = -1, so call LinkedList.AddLast,
LinkedList - [1, 2]
Next vist, index = 3, value = -3, call LinkedList.AddLast
LinkedList - [1, 2, 3]
Next visit, index = 4, value = 5, remove index = 3, 2, since all are impossible to be maximum value, 1 should be removed first since size should be less and equal to 3.

Code assessment practice | C# LinkedList | LinkedListNode | Study notes
I need to take some time to practice LinkedList API in C#, and get familiar with double linked list, and how it is designed in C#.

LinkedList C# Properties
Count, First, Last

LinkedList C# Methods
AddAfter, AddBefore, AddFirst, AddLast, Clear, Contains, CopyTo, Find, FindLast, GetEnumerator, Remove, RemoveFirst, RemoveLast

Time complexity O(N) | Deque data structure | Monotonic decreasing order in sliding window
Maintain the sliding window to keep the maximum value's index in the current window and all other possible index in future windows as well.

The following code passes online judge.

public class Solution {
    public int[] MaxSlidingWindow(int[] nums, int k)
        {
            if (k == 0)
            {
                return nums;
            }

            var length = nums.Length;
            var maxArrayLength = length - k + 1;
            var result = new int[maxArrayLength];

            var deque = new LinkedList<int>();

            // Queue stores indices of array, and 
            // values are in decreasing order (Argue why?)
            // So, the first node in queue should be the index value of the maximum number in window
            for (int index = 0; index < length; index++)
            {
                // 1. remove element from head until first number within window
                if (deque.Count > 0 && deque.First.Value + k <= index)
                {
                    deque.RemoveFirst();
                }

                // 2. before inserting i into deque, remove from the tail of the
                // queue indices with smaller value they array[i]
                while (deque.Count > 0 && nums[deque.Last.Value] <= nums[index])
                {
                    deque.RemoveLast();
                }

                deque.AddLast(index);

                // 3. set the max value in the window (always the top number in
                // queue)
                int maxPosition = index + 1 - k;
                if (maxPosition >= 0)
                {
                    result[maxPosition] = nums[deque.First.Value];
                }
            }

            return result;
        }
}


How to deal with job loss and other issues? | Mental health education | Check list

 Aug. 31, 2021

Introduction

I have to deal with so much stress during pandemic. I like to write a small research blog how to handle the stress in general. 


Large distributed system: Pandemic brings me opportunity to learn better | More time, more progress tracking

Aug. 31, 2021

Introduction

I spent hundreds of hours to work on equity research, and I worried about those hours. How tough it is to make decision to work on something new, not to choose to work on large distributed system. I decided to go back to work on large distributed system design. I have much better experience in 2021. 

Will continue to write 

Breakfast and learn: Bigtable in action (Google Cloud Next '17)

 Aug. 31, 2021

Here is the link. 

Google's billion-user services like Gmail and Google Maps depend on Bigtable to store data at massive scale and retrieve data with ultra low-latency. Today, many use cases such as IoT, finance, mapping, advertising and dealing with time-series data, face similar demands. In this video, you'll learn how to integrate Cloud Bigtable into your application architecture to solve the challenges of storing and retrieving data for these and other use cases. We'll cover the specifics of the Cloud Bigtable service and also dive into schema level design considerations. You'll also hear how customers have successfully leveraged Bigtable to solve their problems at scale and the patterns they've implemented on top of Cloud Bigtable.


CVM stock: Yahoo -> Finance -> Conversation | 160 shares $400 gains

 ===========

QUICK NOTE
===========

Hello CVM fam,

It's been a while I have not posted on this board. Have been busy writing lengthy articles on cvmresearch. I hope those articles, in addition to excellent analysis of No Guess Trading on SA help you feel more comfortable holding CVM.

In the next 12 months or so, until the next binary event (FDA decision), we should expect only positive speculations including:

- Scientific paper in a tier 1 journal. Can't wait more to see what happened with 76 patients who refused to take radio or chem after MK + Surgery
- Feedback from pre-BLA meeting
- Potential expedited program designation (breakthrough and / or fast track)
- Acceptance of BLA / rolling submission
- M&A rumor any time, especially after pre-BLA and scientific publication
- Short or gamma squeezes

PPS is now recovering 50% from bottom but we are no where near the true potential of MK. From scientific angle, I believe that MK the most aggressive and safe approach the cure solid cancers right now. The data has proved it. We are speaking now about a company with good phase 3 data and a full pipeline of phase 2 treatments for solid cancers, a sweet dream of Big Pharma.

Geert and his team (including John Cipriano, an ex senior FDA) are working full speed to secure FDA approval, and as usual, they will OVERDO everything to bring MK to the market. This OVERDO approach makes a lot of sense. You might have seen over-confident but under-prepared company like SESN got killed by the FDA. CEL-SCI will do everything possible so that this will not happen to them.

Exciting months ahead. And as usual, PPS drives emotions and if we keep adding 4-5% per day, we'll see bullish sentiment again very soon.

Good luck to all,

Andy

RIG stock: My $15,000 US dollars position | How to invest as a value investor?

Aug. 31, 2021

Introduction

I like to solve the problem of gambling on my last 10 years full time savings around $64,000 Canadian dollars. I like to put 50% into stock market, and take risk to lose 50% in order for me to learn how business works in pandemic, GTE and RIG, and track how those business performs to work with investors. 

My RIG position | Up and down | Market swing | What is next? 

I thought about missing rebound of TEVA 20%, and then decided to invest $15,000 dollars on RIG stock at price $3.67/ share, and then it went up $600, and then went down $3000 dollars, and then recovered the loss

I learn how to calm myself and do nothing, and then track what is going on about market. I like to learn how market works this dramatic swing, most investors cut loss and sell RIG stocks. RIG stock price went down to $2.8/ share, and I only purchase 100 more shares in my IRA Ameritrade.com USA account at lower price $2.8/ share

I do not like to gamble, since I have worry about bankruptcy of RIG, if delta variant slows down everything. But if it is the case, then I should not worry about money. I should worry about more important things in my life. 

If I do not purchase 4000 shares of RIG, then I will not spend two hours to read RIG quarterly report. I chose to invest on commodity, since it is easy to calculate compared to other business. I like to start from a simple business like oil industry. 

My homework | 50+ oil stocks | My tracking tool 

I also like to track 100 oil stocks, since I know some of oil stock may have very good articles to read under Yahoo -> Finance. I spent a few hours to put together a portfolio in June 2020, and then I named it nicely today so I can lookup more often. 

Reading is No. 1 important as an equity researcher 

I like to read more articles about stocks, so that I can make some bets more often on those $15,000 US dollars. 

Comparison to GTE stock

I also hold 20,000 shares of GTE with around $4000 Canadian dollar loss. I just could not believe that small business is so risky to invest and also it is not shame to lose my capital, I should at least understand one business. 

Follow up 

Feb. 8, 2023

RIG stock price is above $7/ share, only less than 2 years after I wrote the blog. 

It is a good deal to purchase 10000 shares at lowest price as possible ($2.4/ share in Sept. 23. 2022), and then hold it until 2 years or price much higher ($7/ share)




My equity research | Case study 100 share purchase of CRTX | How to stay confidence and learn more about pandemic and business?

 Aug. 31, 2021

Introduction

It is tough for me to evaluate myself on equity research. I need to look into more carefully on my purchase of CRTX 100 shares in Feb. 2021, and then figure out how I missed 300% gains after six months. 

My progress | value investing (1) | margin error | article related to CRTX, big loss stock | My first purchase

I think that it is important for me to spend more time to read and think about articles related to stocks I choose to invest. I should not worry about too much market swing, and spend morning time to study Google cloud technology instead. I should spend time to read more articles in the evening and weekend, and also I need to think about how to enjoy life better as a 55 year old, spend less money to enjoy simple things in life. 

Here is the link related to research related to CRTX. 

Here are some highlights of my lessons:

  1. Do let buy low and sell high, do more research about biotech stock CRTX; hold it and take risk to see how high it might go up; 
  2. Need to work on research how to catch possible 300% return on one of my positions. 

Monday, August 30, 2021

Can 55 year old learn better? | Short memory weakness | Large distributed system | Google BigTable

 Aug. 30, 2021

Introduction

I am not an expert on how human brain works. I am busy working on walking 9 KM project, weight control. Now I am moving to brain research, how memory works better with 55 year old. I am using BigTable as an example. 

Can 55 year old learn better?

I tried to calm myself down, and let market swing, spend time in the morning to watch Google cloud technology channels on youtube.com. I am working hard to learn better about large distributed system. If I have doubt that I will have never use the knowledge in my career, I am still enjoying learning and like to be a master one day. 

I think that there are so many easy-to-understand videos related to BigTable on youtube.com. I like to watch this video again and again, and one day I can memorize the slides. Even though I find out that it is tough to challenge my 55 year old memory brain muscle. 

Follow up

Sept. 1, 2021

First time I like to upload Amazon Polly audio for my blog. 


#CNBC #CNBCTV Fed Chairman Powell speaks at virtual Jackson Hole Economic Policy Symposium – 8/27/2020

Aug. 30, 2021

Here is the link. 

Federal Reserve Chairman Jerome Powell delivers remarks at the virtual Jackson Hole Economic Policy Symposium, hosted by the Federal Reserve Bank of Kansas City. Powell is expected to discuss the Fed’s policy framework and specifically how it will alter its posture on inflation. The Fed has had a 2% inflation target, but in the decade since the financial crisis it has more often than not seen inflation fall below its target.

853. Car Fleet | Code assessment | Preparation

Leetcode: 416. Partition Equal Subset Sum | Medium level | OA preparation | Amazon online assessment

Aug. 30, 2021 

C# Knapsack problems review in July 2019
Here is the link. 


C# depth first search and pruning practice in 2019
Here is the link.

Second practice - C# - Next round - avoid adding more than once
Here is the link. 


First practice in 2020 - C# work on half of all possible sum values
Here is the link.

Mock interview - C# - Hard to tell - add number more than once - Failed 114/115 | 2020 December
Here is the link. 


Dinner and learn: Bigtable in action (Google Cloud Next '17) | Aug 30, 2021

Aug. 30, 2021

Here is the link. 

I like to focus on one slide 


23:44 / 55:07

DBYO: don't build your own

  • abstractions and integrations already exist for popular use cases:
    • graph database
    • time-series database
    • time-series database
    • geospatial querying
Integration with Cloud Dataflow
Integration with Cloud Dataproc

Server Density | Monitoring use case | David Mytton | Co-Founder & CEO

Agenda
  • Old system: PHP + MongoDB
  • Early 2016 - Challenges
  • OpenTSDB + Bigtable selected
  • The migration
  • New system: OpenTSDB + Bigtable
  • Lessons learned #1
  • Lessons learned #2
Old system: PHP + MongoDB

27:55/ 55:07
Early 2016 - challenges

  • Time sink - Spending a lot of time maintaining infrastructure
  • We want to build more - Small team & feature limitations of custom code
  • Unpredictable scaling - New shards, new replicas, impact of migration data around cluster
  • Expensive hardware - SSDs + RAM, Optimising most common uses cases needs data in memory - very expensive 



30:26/ 55:07

Challenges 


OpenTSDB + BigTable selected

  • Managed service - Zero time spent maintaining underlying infrastructure
  • OpenTSDB actively developed - More features than we would have time to build ourselves, but we can contribute upstream
  • Linear scalability - Predictable model for reads/writes and costs
  • Specialist datastore - Specifically designed for time series, so more efficient and lower cost 


805. Split Array With Same Average | Hard level | OA preparation | Aug 30, 2021

Leetcode 410. Split Array Largest Sum | Hard level | OA algorithm to study

 Plan to spend 10 to 20 minutes on this algorithm. 



Sunday, August 29, 2021

Watch Fed chair Jerome Powell's full Jackson Hole speech | My study notes

Aug. 29, 2021

Here is the link.  

Federal Reserve Chair Jerome Powell delivers comments on employment and Fed policy to the virtual Jackson Hole meeting. For access to live and exclusive video from CNBC subscribe to CNBC PRO: https://cnb.cx/2NGeIvi Federal Reserve Chairman Jerome Powell indicated Friday that the central bank is likely to begin withdrawing some of its easy-money policies before the end of the year, though he still sees interest rate hikes off in the distance. In a much-anticipated speech as part of the Fed’s annual Jackson Hole, Wyoming, symposium, Powell said the economy has reached a point where it no longer needs as much policy support.

That means the Fed likely will begin cutting the amount of bonds it buys each month before the end of the year, so long as economic progress continues. Based on statements from other central bank officials, a tapering announcement could come as soon as the Fed’s Sept. 21-22 meeting. However, it does not mean that rate increases are looming. “The timing and pace of the coming reduction in asset purchases will not be intended to carry a direct signal regarding the timing of interest rate liftoff, for which we have articulated a different and substantially more stringent test,” Powell said in prepared remarks for the virtual summit. He added that while inflation is solidly around the Fed’s 2% target rate, “we have much ground to cover to reach maximum employment,” which is the second prong of the central bank’s dual mandate and necessary before rate hikes happen. Markets reacted positively to Powell’s comments, sending major stock indexes to record highs while government bond yields moved lower. Powell also devoted an extensive passage in the speech to explaining why he continues to think the current inflation rise is transitory and will drop eventually to the target level. The Fed has used the term “substantial further progress” as a benchmark for when it will start tightening policy. Powell said that “test has been met” for inflation while there “has also been clear progress toward maximum employment.” He said he and his fellow officials agreed at the July Federal Open Market Committee meeting that “it could be appropriate to start reducing the pace of asset purchases this year.” That question over “tapering” of the minimum $120 billion of monthly bond purchases has had the market’s attention as much for what it means on a mechanical level as for what it signifies when the Fed will start hiking rates.

In an effort to resuscitate the economy during the early days of the Covid-19 pandemic, the Fed took its benchmark rate down to near zero and accelerated its bond buying, or quantitative easing, program to where its balance sheet is now at nearly $8.4 trillion, about double where it was in March 2020. At last year’s Jackson Hole summit, also held virtually, Powell outlined a bold new policy initiative in which the Fed committed to full and inclusive employment even if it meant allowing inflation to run hot for a while. Critics have charged that the policy is partially to blame for current price pressures at their highest levels in about 30 years. However, Powell defended the policy Friday and stressed the importance of the Fed not making an “ill-timed policy move” in response to temporary economic gyrations like the action this year in inflation. “Today, with substantial slack remaining in the labor market and the pandemic continuing, such a mistake could be particularly harmful,” he said. “We know that extended periods of unemployment can mean lasting harm to workers and to the productive capacity of the economy.”

Actionable Items


I like to survey how good I am to read the report. I like to put together some questions first, the answer can be found in the article.

  1. That question over “tapering” of the minimum $120 billion of monthly bond -> Question: How many billions is the monthly bond purchase?
  2. its balance sheet is now at nearly $8.4 trillion, about double where it was in March 2020 -> How many billions in total are purchased since March 2020?
  3. Powell defended the policy Friday and stressed the importance of the Fed not making an “ill-timed policy move” in response to temporary economic gyrations like the action this year in inflation ->

Friday, August 27, 2021

Leetcode 239: Sliding Window Maximum | My discussion post in 2015 | My warmup practice in Aug. 2021 | Amazon OA

Aug. 27, 2021 

239 LinkedList | C# |  LinkedList API | deque data structure

Here is my discussion post. 

I will warm up and practice using C# in short future. 

Amazon OA in past 12 months

第一题是MaximumNumberinSlidingWindow第二题是Turnstile


454. 4Sum II | My practice | Amazon OA | August 27, 2021

 Aug. 27, 2021

Plan to spend 10 minutes to read solution using Leetcode premium version. I will solve the problem and share my discussion post here. 

Here is the link related to Amazon OA discussion. 

The goal | Reduce time complexity from brute force O(N^4) to O(N^2)

Complexity Analysis

  • Time Complexity: \mathcal{O}(n^2). We have 2 nested loops to count sums, and another 2 nested loops to find complements.

  • Space Complexity: \mathcal{O}(n^2) for the hashmap. There could be up to \mathcal{O}(n^2) distinct a + b keys.


Breakfast and learn: Bigtable, BigQuery, and iCharts for ingesting and visualizing data at scale (Google Cloud Next '17)

Aug. 27, 2021 

Here is the link. 

George McMullen - director on icharts 

Carter Page - Engineering manager on BigTable 

Bigtable is a low-latency, high-throughput NoSQL analytical database. BigQuery is a high-performance data warehouse with a SQL API. In this talk, Carter Page and George McMullen discuss how you can use both of these tools together with iCharts to ingest, analyze, and visualize data at scale. Missed the conference? Watch all the talks here: https://goo.gl/c1Vs3h Watch more talks about Infrastructure & Operations here: https://goo.gl/k2LOYG

7:36/ 47:55

What is Cloud Bigtable?

  • Fully managed, noSQL database
  • Petabyte-scale with very low latency
  • Supports sequential row scans
  • Learns and adjusts to access patterns



Breakfast and learn: Bigtable in action (Google Cloud Next '17)

 Aug. 27, 2021

It is my favorite video about bigTable. I started again to watch carefully. I watched twice. 

Here is the link. 

Google's billion-user services like Gmail and Google Maps depend on Bigtable to store data at massive scale and retrieve data with ultra low-latency. Today, many use cases such as IoT, finance, mapping, advertising and dealing with time-series data, face similar demands. In this video, you'll learn how to integrate Cloud Bigtable into your application architecture to solve the challenges of storing and retrieving data for these and other use cases. We'll cover the specifics of the Cloud Bigtable service and also dive into schema level design considerations. You'll also hear how customers have successfully leveraged Bigtable to solve their problems at scale and the patterns they've implemented on top of Cloud Bigtable. Missed the conference? Watch all the talks here: https://goo.gl/c1Vs3h Watch more talks about Infrastructure & Operations here: https://goo.gl/k2LOYG

Thursday, August 26, 2021

Morningstar inc: The Long View: Jason Zweig - Temperament is Everything for Most Investors

Aug. 26, 2021

Here is the link. 

This week's episode of Morningstar’s podcast “The Long View” features Jason Zweig. The author and Wall Street Journal columnist discusses the current trading frenzy, the scorn for expertise, the road to a fiduciary standard, and more.

Talk at Google: The Devil's Financial Dictionary and The Intelligent Investor | Jason Zweig | Talks at Google

 Aug. 26, 2021

Here is the link. 

Jason Zweig will discuss his latest book, The Devil's Financial Dictionary, and how he went about distilling everything he had learned in almost three decades as an investing journalist into definitions of Wall Street terms that are, in many cases, only a few words long. Markets are driven much more by psychology and history than by economics. In writing The Devil's Financial Dictionary, Zweig was guided largely by a saying of his father's: "It's remarkable how much you have to learn in order to realize how little you need to know." “This is the most amusing presentation of the principles of finance that I have ever seen.” —Robert J. Shiller, professor of finance, Yale University; Nobel laureate in economics; author of Irrational Exuberance “Part social commentary, part instruction manual, Zweig’s book is must-reading for anyone who presumes or desires to understand the investment world…. Like the book in which they’re contained, each of Zweig’s entries is pointed, witty, and revealing of important and useful truths. The Devil himself, a.k.a., [Ambrose] Bierce, would be proud.” —TIME

About the Author Jason Zweig writes a weekly column, "The Intelligent Investor," for The Wall Street Journal. He is the author of The Devil's Financial Dictionary, a satirical glossary of financial terms; Your Money and Your Brain, on the neuroscience and psychology of financial decision-making; and The Little Book of Safe Money, an investing guide. The editor of the revised edition of Benjamin Graham's The Intelligent Investor and co-editor of Benjamin Graham: Building a Profession, Zweig also assisted the Nobel Prize-winning psychologist Daniel Kahneman in writing his book, Thinking, Fast and Slow. Before joining The Wall Street Journal, Zweig worked at Money, Forbes and TIME.


Leetcode discuss: 1122. Relative Sort Array

Aug. 26, 2021

Here is the link. 

C# | Counting sort and O(1) lookup using HashMap | 2021 Aug 26

Aug. 26, 2021
Introduction
I chose to practice Leetcode premium Amazon code assessment, so I came cross this algorithm.

C# | List.Sort() API | HashSet | Counting sort using int[] | O(NlogN) time complexity

I tried to put together a few data structure to solve the problem, in other words, put arr2 into a hashset, build a O(1) lookup map to find index by value in arr2, and record count of value in arr2 by counting the occurrence in the array arr1.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArraySort
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr1 = new int[] { 2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19 };
            var arr2 = new int[] { 2, 1, 4, 3, 9, 6 };

            var result = RelativeSortArray(arr1, arr2);
        }

        public static int[] RelativeSortArray(int[] arr1, int[] arr2)
        {
            var length1 = arr1.Length;
            var length2 = arr2.Length;

            var mapCount = new int[length2];
            var set = new HashSet<int>(arr2);
            var indexMap = new Dictionary<int, int>();

            for (int i = 0; i < length2; i++)
            {
                indexMap.Add(arr2[i], i);
            }

            var notIn2 = new List<int>();
            foreach (var item in arr1)
            {
                if (set.Contains(item))
                {
                    var pos = indexMap[item];
                    mapCount[pos]++;
                }
                else
                {
                    notIn2.Add(item);
                }
            }

            notIn2.Sort();

            var list = new List<int>();
            for (int i = 0; i < length2; i++)
            {
                var current = arr2[i];
                for (int j = 0; j < mapCount[i]; j++)
                {
                    list.Add(current);
                }
            }

            foreach (var item in notIn2)
            {
                list.Add(item);
            }

            return list.ToArray();
        }
    }
}

Leetcode discuss: 1155. Number of Dice Rolls With Target Sum

 August 26, 2021

Here is the link. 

C# | Dynamic programming | Two states

Aug. 26, 2021
Introduction
The algorithm can be solved using dynamic programming technique. I like to write down a small case study and explain how to solve it in 10 minutes.

Warmup practice
I chose to practice Leetcode premium, Amazon code assessment. I came cross the algorithm.
Two states, first one is how many dices thrown, second one is sum of those thrown dice face value.

For example, d = 1, f = 6, target = 3, define a dp two dimension C# array, new int[d + 1, target + 1].

Go through three for loops, first one is to work on dice count, next one is to work on dice face value, the third one is to work on summation value of all thrown dice.

My performance
Edge case, first dice only can contribute to dp[1, value], value is dice's value itself. After that, increment value based on dice - 1.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DiceSum
{
    class Program
    {
        static void Main(string[] args)
        {
            // test case: 1, 6, 3, result should be 1
            var result = NumRollsToTarget(1, 6, 3);
            result = NumRollsToTarget(2, 6, 7); 
        }

        /// <summary>
        /// states: 
        /// Dices used: 1 to d
        /// Target value from 1 to target 
        /// 
        /// </summary>
        /// <param name="d"></param>
        /// <param name="f"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public static int NumRollsToTarget(int d, int f, int target)
        {
            var dp = new int[d + 1, target + 1];           

            for (int dice = 1; dice < d + 1; dice++)
            {
                for (int value = 1; value <= f; value++)
                {                                      
                    for (var sum = target; sum >= 1; sum--)
                    {
                        if (sum - value >= 0)
                        {                            
                            if (dice == 1)
                            {
                                if (sum == value)
                                {
                                    dp[dice, sum] = 1;
                                }
                            }
                            else
                            {
                                dp[dice, sum] += dp[dice - 1, sum - value];
                                dp[dice, sum] = dp[dice, sum] % (1000 * 1000 * 1000 + 7);
                            }
                        }
                    }
                }
            }

            return dp[d, target];
        }
    }
}