From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Thursday, May 12, 2022
Wednesday, May 11, 2022
Vancouver pollen index update
May 11, 2022
It is the date I like to remember. May 11, 2022, pollen index is moderate based on Vancouver pollen index website. Here is the website.
Pollen index
Pollen - Moderate
May 11, 12, 13,
- Low Alder
- Low Cedar, Juniper, etc |
- Low Boxelder, Maple
Tech companies | Recession | 2022 May
Amid global chaos, the tech industry takes a rare tumble
Despite tough times looming, Silicon Valley investors say things could be worse
The collapse has affected even the most dependable bulwarks. Apple, despite record revenue, went from being worth $3 trillion in January to $2.5 trillion Monday. Microsoft, Amazon, Tesla and Alphabet have all lost more than 20 percent of their value this year. Netflix has lost 70 percent.
Facebook, which is down 40 percent this year, told its employees recently that it would freeze hiring, which in the tech industry will mean an all-but-certain drop in overall head count. Private start-ups, sheltered from the stock market, have also felt the pain, with 29 companies laying off employees since the beginning of April, according to Layoffs.fyi, which tracks layoffs in the tech industry.
That includes Robinhood, the financial services company; Cameo, the app that lets users pay for personalized videos from their favorite celebrities; and On Deck, a Silicon Valley darling that helps tech talent start companies, secure funding or find jobs.
This is a major turn for the tech industry, which for more than a decade has defied gravity, continuing to expand beyond what even the industry’s biggest fans thought was possible. Now, with an economy stretched by the global pandemic and jostled by war, the once largely immune tech industry may have found its match.
“There’s a lot of factors, a lot of head winds that have people worried,” said Greg Martin, managing director of Rainmaker Securities, which facilitates trading of privately held technology companies’ shares. “I’ve been doing this since the late ’90s. I’ve seen patterns like this. This feels very different.”
Andrea Beasley, spokeswoman for Meta-owned Facebook, said the company is slowing its talent pipeline according to its business needs. In a statement, Cameo chief executive Steven Galanis wrote that the company’s workforce grew from 100 to 400 during the pandemic, and described the layoffs decision as a “painful but necessary course correction.”
In a blog post, Robinhood chief executive and co-founder Vlad Tenev wrote that the company’s head count grew from 700 to 3,800 during a period of hyper growth accelerated by pandemic shutdowns, low interest rates and fiscal stimulus, leading to duplicate jobs.
The other companies declined or did not respond to requests for comment.
The Nasdaq’s churn continued Tuesday, with the tech-heavy index rebounding 2 percent in morning before reversing course and turning negative, then finishing the day up 1 percent at 11,738. The oscillation comes after it racked up a dizzying 4 percent decline to kick off the week. In April, the Nasdaq notched its worst month since 2008.
After touching an all-time low Monday, Peloton’s shares slumped more than 15 percent after the company reported a $757 million loss last quarter and its first year-over-year decline in revenue. Its stock is now down nearly 63 percent year-to-date.
During the dot-com bust in 2000, highflying Silicon Valley companies buoyed by overhyped stocks disintegrated overnight. The impact was so immediate and dramatic that Bay Area traffic thinned out and parking was easier to find.
By 2004, the industry found its footing again. Companies such as Facebook set up shop, and soon the industry was booming. Despite a global financial crisis and speculation of another bubble burst, the trajectories of companies such as Facebook and Google stayed on course. Then came Uber, Airbnb and Twitter, all of which faced skepticism about their lofty valuations before going public.
For more than a decade, some investors have wondered whether a crash reminiscent of 2000 was coming. But it hasn’t materialized, even as the coronavirus shut the world down.
So far, that’s in large part because today’s tech industry looks different from the one in 2000.
It’s more global, with major companies spread out across the United States, Europe and Asia. Investors now include not just storied venture capital firms such as Sequoia and Benchmark but major players in the financial markets, such as Tiger Global, which earlier this year committed $1 billion for early-stage tech start-ups.
Companies such as Uber and WeWork were funded in part by money from the Kingdom of Saudi Arabia via the Japanese firm SoftBank. According to the National Venture Capital Association, 2021 alone attracted 17,000 venture capital deals, worth a record $330 billion.
And while investors might think the stock price for incredibly valuable companies including Apple, Amazon, Facebook and Google could be overpriced, they have built sprawling and largely profitable businesses.
Still, Amazon recently reported a surprising loss and said its warehouses were overstaffed. And shareholders’ demand to see profitability — and distrust in the business model for the once-bullish ride-sharing sector — was the theme of Uber chief executive Dara Khosrowshahi’s recent email to employees.
“The average employee at Uber is barely over 30, which means you’ve spent your career in a long and unprecedented bull run. This next period will be different,” he wrote, according to media reports.
Still, the downturn affecting the technology industry today is showing no signs of turning catastrophic yet.
“I had a conversation today with an early-stage investor and none of us had any data yet showing there are fewer companies being started because of this,” said Beezer Clarkson, a partner at Sapphire Partners who invests in early-stage venture capital firms. “That would be a very worrisome sign if people were choosing not to innovate or start companies, so it’s something we are continuing to watch closely.”
Venture capital investors, some of whom spoke with The Washington Post on the condition of anonymity because of the sensitivity of their investments, said the downturn isn’t affecting their investment strategies.
But they said start-ups needed to pay attention to their “burn rate,” Silicon Valley lingo for the amount of investment capital they are spending, because it may become more difficult to raise more funding rounds. Because most early-stage start-ups lose money, the amount they “burn” determines how long they can survive between funding rounds, known as “runway.”
Rather than pull back on investing in start-ups, Clarkson said, investors are saying they’re looking at companies more critically, asking them to use their funding more efficiently. “You can make the argument that’s not necessarily terrible. Looking at metrics should not be a negative.”
Tod Francis, co-founder of venture firm Shasta Ventures, said it was easy for start-ups to raise capital in recent years and that the markets valued growth over profitability. Start-ups responded by hiring aggressively.
He said he expects companies to adjust to the market turmoil by reducing areas that aren’t as essential, such as marketing. “Investors will be putting more value in business models and capital efficiency,” Francis said.
A downturn in large tech companies can also benefit the next wave of start-ups. When companies such as Facebook and Netflix stop hiring or lay off employees, some of those employees often found or join start-ups, which may have looked risky compared with the security of a large company.
Employees at publicly traded tech companies often receive a significant portion or even a majority of their salaries in the form of stock. As stock prices go down, the salaries offered by large tech firms look less and less attractive relative to smaller start-ups.
Private tech companies aren’t traded on the public stock market, so their true value is often difficult to calculate. But some employees sell their stock on private markets reserved for sophisticated investors. The prices of those “secondary shares” can provide a sense of whether the value of a company is rising or falling.
Martin, who facilitates secondary market trades at Rainmaker Securities, said the shares of some private companies are being traded at a steep discount. But he said some start-ups have begun to clamp down, preventing shareholders from trading shares to avoid the perception that the company is less valuable.
A down market can create problems for start-up employees that go beyond layoffs. Employees at start-ups are often compensated with stock options that they are allowed to purchase at prices below what outside investors are willing to pay. Employees must wait to sell those shares until the company goes public or is acquired, or, if they are permitted, to sell on the secondary markets. But employees must pay taxes on the stock options before selling them. If the company fails, the employee will have paid taxes for nothing.
Some Silicon Valley entrepreneurs and investors are skeptical that anything serious is amiss.
“Hiring got really out of control and work didn’t really change in a meaningful way during covid, so I wonder how much of this is big companies using the macro softness to clean house,” said Sarah Kunst, founder of venture firm Cleo Capital.
On ZipRecruiter, a job listing site, the number of active job postings in the tech industry increased between January and April for all available jobs, including project management and software development, said the company’s lead economist, Sinem Buber.
“Since technical skills are highly desirable across all industries from online retail to fintech, skilled workers have a lot of options in the job market right now,” Buber said.
Still, fears about layoffs are ricocheting across Blind, the anonymous messaging app popular with tech employees, where thousands of users voted in a poll asking which tech company would cut jobs next.
Facebook parent company Meta has frozen hiring for mid-level and junior engineers, a current employee who spoke on the condition of anonymity to discuss sensitive matters told The Post. And internal communication shared with the paper said that because fewer recruiters would be needed, some upcoming recruiter contractor engagements were being canceled.
“Impacted contractors were notified immediately and offered a financial transition package” from their formal employers, according to a post viewed by The Post. It warned readers not to speak to the media or discuss the layoffs online.
The post emphasized that employees were not affected. It also noted that Meta would be hiring fewer people than originally planned for 2022.
Board member Marc Andreessen wrote that workforces needed to be slashed after years of unbridled spending.
“The good big companies are overstaffed by 2x. The bad big companies are overstaffed by 4x or more,” he posted on Twitter.
Elon Musk, who has said he plans to buy Twitter for roughly $44 billion, has suggested hiring 3,600 employees, after shedding hundreds of jobs, according to a pitch deck viewed by the New York Times.
Musk, who is CEO of electric car company Tesla and rocket company SpaceX, is facing concerns from employees and investors that he might be stretched too thin. He has put up much of his personal wealth to fund the acquisition — expected to be a large portion of his Tesla stake.
On Tuesday, Musk said at an auto conference that, should he go through with the Twitter acquisition, he’ll reinstate former president Donald Trump, who was banned indefinitely from the platform for violating its terms of service.
Tesla’s stock is down 20 percent since Musk made his offer to acquire Twitter.
Taylor Telford contributed to this report.
Tuesday, May 10, 2022
Leetcode discuss: 957. Prison Cells After N Days
Here is the link.
C# | Quick learner | Bit manipulation warmup | Avoid TLE error
May 10, 2022
I am warmup algorithms to prepare for Google phone screen in 2022. I like to learn and learn quickly.
Introduction
To be a quick learner, I always like to read at least three solutions, and also write C# solutions based one Leetcode discuss post.
Analysis | Intuition | votrubac
Based on the following constraints given in problem statement, we can easily to discuss the scope of problem based on n in range of 2^9, cells.Length = 8.
Constraints:
cells.length == 8
cells[i] is either 0 or 1.
1 <= n <= 10^9
If cells's length is 8, in other words, there are 8 cells, since each cell is either 0 or 1, so the number of all the possible state combinations is 2^8 = 256. This means when N > 256, cells will have the same state as its orignal 256 states. So we expedite the search, avoid time out, reduce calculatuion of next state from n to [loop size] + n % [loop size]. It is challenge task to determine how to take minimum calculation approach in design stage.
For example, given n = 1,000,000, cells is an integer array with size 8, so the total steps to calculate is reduced from n to 256 + n %256, which is at most 512. Reduction from 1,000,000 to 512 is big success to solve this problem without TLE problem.
Using 2^8 vs HashSet | Random state
Since integer array cells's length - denoted as L determines at most 2^L states, it is random process to determine next state, so we can not determine how many states to end the cycle, therefore, we need to store all possible states and use HashSet to determine if it is seen in previous steps.
Of course, it is a good practice to write a solution using bit manipulation. I will try it as well.
Complexity Analysis
Runtime: O(2 ^ n), where n is the number of cells (not days). For 8 cells, we can have 64 different states.
Memory: O(n). We need to remember a single state of all cells for the loop detection. For 8 cells, the complexity is O(1).
The following C# code passes online judge.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _957_prison_state_after_N_days___bit
{
class Program
{
static void Main(string[] args)
{
//Input: cells = [0,1,0,1,1,0,0,1], n = 7
//Output: [0,0,1,1,0,0,0,0]
var test = new Program();
var result = PrisonAfterNDays(new int[] { 0, 1, 0, 1, 1, 0, 0, 1 }, 7);
Debug.Assert(String.Join(",", result).CompareTo("0,0,1,1,0,0,0,0") == 0);
}
/// <summary>
/// study code
/// https://leetcode.com/problems/prison-cells-after-n-days/discuss/1769581/C-bitwise-op
/// </summary>
/// <param name="cells"></param>
/// <param name="n"></param>
/// <returns></returns>
public static int[] PrisonAfterNDays(int[] cells, int n)
{
// using 8 bits integer to reprenst each cell in given cells array
var bits = 0;
for (int i = 0; i < cells.Length; i++)
{
// left shift i bits - each cell maps to one bit from left to right
// | - or operator
bits |= (cells[i] << i);
}
var map = new Dictionary<int, int>();
int step = 0;
int state = bits;
while (!map.ContainsKey(state))
{
map.Add(state, step);
step++;
//01111110 - 8 bits - first bit and last bit will not change
//01111110 - 8 bits - integer 126 = 2 ^7 - 1 - 1 = 128 - 1 - 1 = 126
// if it is easy to understand the above calcuation, then go ahead to read the code
// shift k left and right to get the next state
// left shift one bit -
var leftShift = (state) << 1;
var rightShift = (state) >> 1;
// XOR operator ^, 1 ^ 1 = 0, 1 ^ 0 = 1, 0 ^ 0 = 0
// Bitwise Complement Operator (~ tilde)
// the bitwise complement operator is a unary operator
// (works on only one operand). It takes one number and
// inverts all bits of it. When bitwise operator is applied on bits then,
// all the 1’s become 0’s and vice versa. The operator for the bitwise complement is ~ (Tilde).
//
state = ~(leftShift ^ rightShift) & 126;
}
int entryStep = map[state];
int L = step - entryStep;
// avoid TLE error
if (n >= entryStep)
{
n = (n - entryStep) % L + entryStep;
}
state = bits;
for (int i = 0; i < n; i++) // walk n steps from oringal state
{
state = ~((state >> 1) ^ (state << 1)) & 126;
}
var result = new int[8];
for (int i = 0; i < cells.Length; i++)
{
// left shift >> i, and determine if it is 0 or 1
result[i] = (state >> i) & 1;
}
return result;
}
}
}Leetcode discuss: 957. Prison Cells After N Days
Here is the link.
C# | Quick learner in 30 minutes | TLE concern in algorithm design | using HashSet
May 10, 2022
Introduction
To be a quick learner, I always like to read at least three solutions, and also write C# solutions based on Leetcode discuss posts shared by others.
Analysis | Intuition | votrubac
Based on the following constraints given in problem statement, we can easily to discuss the scope of problem based on n in range of 2^9, cells.Length = 8.
Constraints:
cells.length == 8
cells[i] is either 0 or 1.
1 <= n <= 10^9
If cells's length is 8, in other words, there are 8 cells, since each cell is either 0 or 1, so the number of all the possible state combinations is 2^8 = 256. This means when N > 256, cells will have the same state as its orignal 256 states. So we expedite the search, avoid time out, reduce calculatuion of next state from n to [loop size] + n % [loop size]. It is challenge task to determine how to take minimum calculation approach in design stage.
For example, given n = 1,000,000, cells is an integer array with size 8, so the total steps to calculate is reduced from n to 256 + n %256, which is at most 512. Reduction from 1,000,000 to 512 is big success to solve this problem without TLE problem.
Using 2^8 vs HashSet | Random state
Since integer array cells's length - denoted as L determines at most 2^L states, it is random process to determine next state, so we can not determine how many states to end the cycle, therefore, we need to store all possible states and use HashSet to determine if it is seen in previous steps.
Of course, it is a good practice to write a solution using bit manipulation. I will try it as well.
Complexity Analysis
Runtime: O(2 ^ n), where n is the number of cells (not days). For 8 cells, we can have 64 different states.
Memory: O(n). We need to remember a single state of all cells for the loop detection. For 8 cells, the complexity is O(1).
I just warmup the algorithm using less than 30 minutes.
The following C# code passes online judge.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _957_prison_cells_after_N_days
{
class Program
{
static void Main(string[] args)
{
//Input: cells = [0,1,0,1,1,0,0,1], n = 7
//Output: [0,0,1,1,0,0,0,0]
var test = new Program();
var result = test.PrisonAfterNDays(new int[] { 0, 1, 0, 1, 1, 0, 0, 1 }, 7);
Debug.Assert(String.Join(",", result).CompareTo("0,0,1,1,0,0,0,0") == 0);
}
/// <summary>
/// study code
/// https://leetcode.com/problems/prison-cells-after-n-days/discuss/634109/C-solution
/// </summary>
/// <param name="cells"></param>
/// <param name="n"></param>
/// <returns></returns>
public int[] PrisonAfterNDays(int[] cells, int n)
{
if (cells == null || cells.Length == 0 || n <= 0)
{
return new int[0];
}
// store all the seen/visited states
var seen = new HashSet<string>();
var count = 0;
var length = cells.Length;
var nextState = new int[length];
while (n > 0)
{
nextState = getNextState(cells);
var state = string.Join("", nextState);
if (seen.Contains(state))
{
break;
}
seen.Add(state);
// only update cells when its state was not seen before
// the state will be the starting state for the remaining n%k days
Array.Copy(nextState, cells, length);
// count the actaul no. of days that have no duplicated states
count++;
n--;
}
// update the state for the remaining n%k days
n %= count;
while (n > 0)
{
cells = getNextState(cells);
n--;
}
return cells;
}
/// <summary>
/// If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied.
/// Otherwise, it becomes vacant.
/// </summary>
/// <param name="cells"></param>
/// <returns></returns>
private int[] getNextState(int[] cells)
{
var length = cells.Length;
// default is zero - vacant
var nextDayCells = new int[length];
for (int i = 1; i < length - 1; i++)
{
if (cells[i - 1] == cells[i + 1])
{
nextDayCells[i] = 1;
}
}
return nextDayCells;
}
}
}CPI report tomorrow is very important, says Cerity's Jim Lebenthal
May 10, 2022
Here is the link.
Jim Lebenthal, Cerity Partners chief equity strategist, joins the 'Halftime Report' to discuss whether or not stocks have reached the bottom and the importance of tomorrow's Consumer Price Index report. For access to live and exclusive video from CNBC subscribe to CNBC PRO: https://cnb.cx/2NGeIvi
Bear market - take years to recover
Correction - less than one year
False bottoms - four bottoms, final bottom came in around 2015
Below 8% - good sign - technical bottom

I have issues called loss aversion, and I did not cut loss early when price was around $9.8/ share. Need to get back in at lower price.
I'm bullish on the markets, says BMO's chief investment strategist Brian Belski
May 10, 2022
Brian Belski, BMO chief investment strategist, joins 'Closing Bell: Overtime' to discuss his view on the markets and economy. For access to live and exclusive video from CNBC subscribe to CNBC PRO: https://cnb.cx/2NGeIvi
Investors
nervous
position for down side
no one for update
8.5% CPI | Federal is still high
Market ahead of Fed
Fed raise rate
Bond market
2.6% percent
BMO's chief investment strategist - Brian Belski
CPI - inflation is peaked - May 11, 2022