A **wonderful** string is a string where **at most one** letter appears an **odd** number of times.

- For example,
`"ccjjc"`

and`"abab"`

are wonderful, but`"ab"`

is not.

Given a string `word`

that consists of the first ten lowercase English letters (`'a'`

through `'j'`

), return *the **number of wonderful non-empty substrings** in *`word`

*. If the same substring appears multiple times in *`word`

*, then count **each occurrence** separately.*

A **substring** is a contiguous sequence of characters in a string.

**Example 1:**

**Input:** word = "aba"

**Output:** 4

**Explanation:** The four wonderful substrings are underlined below:

- "**a**ba" -> "a"

- "a**b**a" -> "b"

- "ab**a**" ->…

Stop the grind. Study with plan! Here’s the patterns that covers 95% of the questions you’ll see on LeetCode.

**Overview**

Sorted Array

Implicitly Sorted Array

Introduction

DFS on Tree

- Introduction
- Max Depth of A Tree
- Visible Tree Node
- Valid Binary Search Tree
- Serializing and Deserializing Binary Tree
- Lowest Common Ancestor

**Backtracking**

Combinatorial Search

Memoization

Pruning

The first step to getting a job at Google is to pass the online assessment, commonly referred as “OA”. The OA is given to candidates immediately after your application is approved by the initial screening. If you pass the online assessment, you will move on to the next round which is commonly phone interview screening. Although a recruiter may skip online assessment based on role/position and years of experience. In 2021, certain Google offices are skipping online assessment together.

The most common format of an OA is two coding questions to complete them within one hours to 90 minutes. The…

The first step to getting a job at Twitter is to pass the online assessment, commonly referred as “OA”. The most common format is a test with two to three questions to complete them within 1–1.5 hours. The assessment result will be used to decide if the candidate can move on to the on-site interviews.

The first step to getting a job at Amazon is to pass the online assessment, commonly referred as “OA”. Candidates are sent a test with 1–2 questions to complete them within 1.5 hours. The assessment result will be used to decide if the candidate can move on to the on-site interviews.

Here we have compiled a list of all online assessment questions for you:

In a string composed of `'L'`

, `'R'`

, and `'X'`

characters, like `"RXXLRXRXL"`

, a move consists of either replacing one occurrence of `"XL"`

with `"LX"`

, or replacing one occurrence of `"RX"`

with `"XR"`

. Given the starting string `start`

and the ending string `end`

, return `True`

if and only if there exists a sequence of moves to transform one string to the other.

**Example 1:**

**Input:** start = "RXXLRXRXL", end = "XRLXXRRLX"

**Output:** true

**Explanation:**

We can transform start to end following these steps:

RXXLRXRXL ->

XRXLRXRXL ->

XRLXRXRXL ->

XRLXXRRXL ->

XRLXXRRLX

**Example 2:**

**Input:** start = "LLR", end = "RRL"

**Output…**

Given a **complete** binary tree, count the number of nodes.

**Note:**

**Definition of a complete binary tree from ****Wikipedia****:**

In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.

**Example:**

Input:

1

/ \

2 3

/ \ /

4 5 6Output:6

Asked recently by Google, Amazon and Microsoft.

The trivial solution is to traverse the tree and count the number of nodes and that would cost…

Given `n`

nodes labeled from `0`

to `n-1`

and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.

**Example 1:**

**Input:** n = 5, and edges = [[0,1], [0,2], [0,3], [1,4]]

**Output:** true

**Example 2:**

**Input:** n = 5, and edges = [[0,1], [1,2], [2,3], [1,3], [1,4]]

**Output:** false

Before solving the problem, we have to know the definitions.

A tree is a special undirected graph. It satisfy two properties

- It is connected
- It has no cycle.

Being connected means you can start from…

“Dynamic programming”, an awfully scary name. What does it even mean?? What’s so “dynamic” about programming?

The name was invented by Richard Bellman in the 1950s when computers are still decades away. So by “programming” he really did NOT mean programming as in coding at a computer. Bellman was a mathematician, and what he really meant by programming was “planning” and “decision making”.

Trivia time: according toWikipedia, Bellman was working at RAND corporation, and it was hard to get mathematical research funding at the time. To disguise the fact that he was conducting mathematical research, he phrased his research…

Dynamic programming is probably the trickiest and most-feared interview question type. The hardest parts are 1) to know it’s a dynamic programming question to begin with 2) to find the subproblem.

We looked at a ton of dynamic programming questions and summarized common patterns and subproblems.

We also highlighted the keywords that indicate it’s likely a dynamic programming problem.

This is the most common type of DP problem and a good place to get a feel of dynamic programming. In the recurrence relation,**dp[i]**** normally means max/min/best value for the sequence ending at index i.**

- House robber — find
**maximum**amount…

10x your algorithm interview prep speed. Take the 5-minute quiz: https://algo.monster/quiz