---
title: "Brian Hu (@brianhu) | Hashnode"
description: "Brian Hu (@brianhu) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@brianhu"
---

@brianhu

# Brian Hu

@brianhu · Joined August 2022

### [89\. Gray Code](https://brianhu.hashnode.dev/89-gray-code?utm_source=hashnode&utm_medium=feed)

Link key ideas Create an array res with size 2^n Set res\[0\] = 0 as the base case Iterate over the array, trying to insert a valid number in every iteration. To find a valid number, we create another loop, and in this nested loop: toggle the righ...

2 min read · [brianhu.hashnode.dev](https://brianhu.hashnode.dev/89-gray-code?utm_source=hashnode&utm_medium=feed)

[Dec 24, 2022](https://hashnode.com/posts/89-gray-code/63a6f5bc6e98c84377a62f0c)

### [33\. Search in Rotated Sorted Array](https://brianhu.hashnode.dev/33-search-in-rotated-sorted-array?utm_source=hashnode&utm_medium=feed)

link Key ideas If we split the rotated array from the mid, there must be a sorted half and an unsorted half \[5, 6, 1, 2, 3, 4\] -> \[5, 6, 1\] (unsorted) + \[2, 3, 4\] (sorted) \[5, 6, 1\] -> \[5\] (sorted) + \[6, 1\] (unsorted) We can apply regular binary...

2 min read · [brianhu.hashnode.dev](https://brianhu.hashnode.dev/33-search-in-rotated-sorted-array?utm_source=hashnode&utm_medium=feed)

[Oct 1, 2022](https://hashnode.com/posts/33-search-in-rotated-sorted-array/6337ff319de1896c308897d9)

### [Pairs from an array](https://brianhu.hashnode.dev/pairs-from-an-array?utm_source=hashnode&utm_medium=feed)

Input \[1,2,3,4\] Output \[(1, 2), (3, 4)\] \[(1, 3), (2, 4)\] \[(1, 4), (2, 3)\] Key ideas We want to generate combinations from the input, and we don't know how many combinations there are -> this is a hint to use the backtracking strategy When we pick a...

2 min read · [brianhu.hashnode.dev](https://brianhu.hashnode.dev/pairs-from-an-array?utm_source=hashnode&utm_medium=feed)

[Sep 18, 2022](https://hashnode.com/posts/pairs-from-an-array/63274bc4b1a2e9b8401e1239)

### [Maximum Product Subarray](https://brianhu.hashnode.dev/maximum-product-subarray?utm_source=hashnode&utm_medium=feed)

link Key ideas We want to have even or 0 negative numbers in the subarray, so that the product will be positive. The challenge is we never know if we will eventually get even negative numbers, so we need to maintain 3 variables local\_max: the maxi...

2 min read · [brianhu.hashnode.dev](https://brianhu.hashnode.dev/maximum-product-subarray?utm_source=hashnode&utm_medium=feed)

[Sep 10, 2022](https://hashnode.com/posts/maximum-product-subarray/631cb0ebf73f4734bc054af1)

### [53\. Maximum Subarray](https://brianhu.hashnode.dev/53-maximum-subarray?utm_source=hashnode&utm_medium=feed)

link Key ideas We can extend the subarray if the sum is still positive after adding the next number If adding the next number makes the sum negative, it means adding the next number doesn't help us get the maximum, we definitely don't want to have i...

1 min read · [brianhu.hashnode.dev](https://brianhu.hashnode.dev/53-maximum-subarray?utm_source=hashnode&utm_medium=feed)

[Sep 9, 2022](https://hashnode.com/posts/53-maximum-subarray/631b40a9f73f4734bc05152b)
