# [MySQL][LeetCode][Easy] 181. Employees Earning More Than Their Managers

The `Employee` table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.

Given the `Employee` table, write a SQL query that finds out employees who earn more than their managers. For the above table, Joe is the only employee who earns more than his manager.

1. Sub Select
2. Join
3. From

# [C#][LeetCode][Easy] 476. Number Complement

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.

Note:

1. The given integer is guaranteed to fit within the range of a 32-bit signed integer.
2. You could assume no leading zero bit in the integer’s binary representation.

1. Normal – 硬幹
2. LinQ

# [C#][LeetCode][Easy] 226. Invert Binary Tree

Invert a binary tree.

to

1. 遞迴

# [C#][LeetCode][Easy] 136. Single Number `^` = `運算子` = `XOR`

1. `001` ^ `010` = 011
2. 011 ^ `011` = 000
3. 000 ^ `100` = 100
4. 100 ^ `001` = 101
5. 101 ^ `010` = 111
6. 111 ^ `011` = 100
7. 100 轉十進位則是 4，由此可知答案是4

Given an array of integers, every element appears twice except for one. Find that single one.

1. Normal
2. LinQ (Time Out)

1. 邏輯異或
2. 大神朋友

# [C#][LeetCode][Easy] 258. Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

For example:

Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it.

1. For + 遞迴
2. LinQ + 遞迴
3. Normal

# [C#][LeetCode][Easy] 389. Find the Difference

Given two strings s and t which consist of only lowercase letters.

String t is generated by random shuffling string s and then add one more letter at a random position.

Find the letter that was added in t.

# [C#][LeetCode][Easy] 104. Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.

The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.

# [C#][LeetCode][Easy] 204. Count Primes

Count the number of prime numbers less than a non-negative number, n.

1. Eratosthenes演算法
2. LinQ (Time Limit Exceeded)
3. Nomal –  硬幹(Time Limit Exceeded)
4. Nomal –  稍微聰明一點的硬幹(Time Limit Exceeded)
由於可以知道只要是2的倍數絕對不會是質數，所以迴圈就直接`i+=2`了，殊不知還是Time Out…

# [C#][LeetCode][Easy] 242. Valid Anagram

Given two strings s and t, write a function to determine if t is an anagram of s.

For example,
s = “anagram”, t = “nagaram”, return true.
s = “rat”, t = “car”, return false.

Note:
You may assume the string contains only lowercase alphabets.

• LinQ – `OrderBy`
• LinQ – `Sort`
• Normal – Array.Sort
• Normal – 硬幹 (會 Time Limit Exceeded)

# [C#][LeetCode][Easy] 292. Nim Game

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.

Both of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.

For example, if there are 4 stones in the heap, then you will never win the game: no matter 1, 2, or 3 stones you remove, the last stone will always be removed by your friend.

Hint:

If there are 5 stones in the heap, could you figure out a way to remove the stones such that you will always be the winner?