Skip to main content


Recent posts

LeetCode 129 Sum Root to Leaf Number

  LeetCode 129 Sum Root to Leaf Numbers Given a root of binary tree containing digits from 0 to 9 only. Return the total sum of all root to leaf. The question is taken from the book “ Elements of Programming Interviews in Python ” page 125 We see we have here these routes to path 495 +491 +40 Which in total is 1026 Now let’s see how to solve it in java /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, TreeNode left, TreeNode right) { * this.val = val; * this.left = left; * this.right = right; * } * } */ class Solution { // This is an excellent trick to save us from passing params. int total = 0; public int sumNumbers(TreeNode root) { sumNumbers(root, 0); return total; } private void sumNumbers(Tr

Java ForkJoin Pool CheatSheet

Java ForkJoin Pool # Java ForkJoin Pool 1. As it sounds, assist distribute work 2. From java 7 3. Based on Doug Lea's work 4. As it sounds, break to simpler tasks    1.  Ideally, no worker thread idle        1.  Threads steal work 5. Classes you use    1.  ForkJoinPool        1.   Implements ExecutorService        2.   `ForkJoinPool = new ForkJoinPool(int parallelism)`             1.   With no arg by default, numProcessors        3.   Pool adjusts its size! (though you specified number)   1.   Send ForkJoinPool Tasks with        1.    Execute() - asynchronous        2.    invoke() - sync awaits        3.    submit() - Async get Future    2.  ForkJoinTask        1.  isDone() - true when complete        2.  isCompletedNormally() - finished without exception        3.  isCompletedAbnormally() - true cancelled / exception 6.  How to use     1. Create `RecursiveTask`     2. Implement `compute()` in RecursiveTask to do your work        1. You can create additional tasks inside it, that&#

DynamoDb Read Capacity Units - RCU

1. DynamoDb Max Item Size is 400KB 2. 1 RCU is ~1 Read request from the DB 3. Why is it only roughly 1 read request because we could have multiple types of read requests 4. We could have a consistent read request 5. We could have an eventual consistent read request 6. We could have a transactional read request 4. If the item we read is up to 4kb and we read with eventual consistent than we could actual make 2 such items read with 1 RCU 5. If the item i up to 8KB and we make an eventual consistent read than we could have a single read request per second with 1 RCU 6. If the item is larger than 4KB and we want to perform a consistent read request than this would require 2 read request at least. 7. If we need a transactional read request for an item up to 8KB then we would need even 4 RCU 8. If we need a transactional read request for an item up to 4KB then we would need 2 RCU that is because transactional read requires 2 phase commit the first RCU would be for prepare and the secon

4 Core Patterns for SEO

Relevance Your content is relevant to keywords On-page optimization In the past, could just repeat keywords Today, content keywords should be related Think TOPIC Not keywords Divide web pages by topics not by keywords Many pages same topic—google will get confused Aggregate keywords to topics Identify primary keyword within topic Topic in Url's Not good too deep – isn't that important Title tag title  tag Header tags <h1>⁣ – Best  description of the web page <h2>⁣ – Synonyms  to topic <h3+>⁣ – You  don't have to optimize Keyword density copy from results 1 – 5 How many times your keyword appear vs your total words in your page Use tool LSI Latent Semantic indexing Prove you are on that topic if you discuss java interview tips, I guesstimate problem coding works would be in your p

LeetCode 3| Longest Substring Without Repeating Characters | Medium

Problem Given a string  s , find the length of the  longest substring  without repeating characters. ie. weqwjfd --> 4  (because wjfd is 4 chars) Problem Analysis String/Array Find elastic string within substring Though they asked to find the substring in examples they gave, they had the length  of the largest substring So, we need to return the length Thinking about solution We have a string we are going to need to scan it Largest --> elastic find the boundaries of the string Elastic + Array/String --> Sliding-Window  == TwoPointers But Sliding-Window class Solution {     public int lengthOfLongestSubstring ( String s ) {         int l = 0 ;         int result = 0 ;         Set < Character > set = new HashSet <>();         // We start with right pointer from 0, both left and right are at 0!.         for ( int r = 0 ; r < s . length (); r++) {             // As long as we have duplicates move left first. Trick! at first 0,0 no duplicates!          


 What is stagflation? Stagflation is an economic state where we have both below economical states happening simultaneously, inflation and no growth.  We can have periods of inflation, we can have periods of no growth, but when we have them together, we call this stagflation. So, stagflation is when we have both: We have inflation We don't have growth Let's define inflation , we have two mainstream definitions: Price inflation – the prices are getting higher We have a measure of a few goods in a basket – warning which goods The weight of these goods in this index changes over time to reflect their real life ratio Monetary inflation – increase in money supply Usually increase in money supply should reflect the actual economic growth We actually see big inflation in a combination of both price inflation and also monetary inflation.  During inflation periods, we have brief stagflation periods. Presently, we have over 4 decades of disinflation, but since 2020+ we started having co