---
# System prepended metadata

title: Summary_April
tags: [Microsoft, Google]

---

# Summary_April

## Plan x Reality


| # | Category | Title | Note | Start Date | End Date |
|--------| -------- | -------- | -------- | -------- | -------- |
| 1| Bit Manipulation     | Single Number   | New    | 2024.04.07 |2024.04.07| 
| 2| Math & Geometry      |Multiply Strings | Review [Microsoft]()| 2024.04.08 |2024.04.16|
| 3| Math & Geometry      |Pow(x, n) | Review |2024.04.09 |2024.04.14|
| 4| Math & Geometry | Plus One |Review [Microsoft]()|2024.04.11| 2024.04.16 |
| 5| Math & Geometry | Happy Number |Review |- | 2024.04.15 | 
| 6| Math & Geometry | Reverse Integer |Review |2024.04.13 |2024.04.14|

### LeetCode Profile
`https://leetcode.com/Yu_135/`


| Date | Solved | Remark |
| -------- | -------- | -------- |
| 2024.04.07     | 187     |      |
| 2024.04.07     | 188     | ADD `Single Number`    |

#### NeetCode 150
`https://neetcode.io/practice`
| Date | Solved | Remark |
| -------- | -------- | -------- |
| 2024.04.07     | 144 / 150     |      |
| 2024.04.07     | 145 / 150     | ADD `Single Number`     |
| 2024.04.14     | 146 / 150     | ADD `Reverse Integer`     |
| 2024.04.15     | 148 / 150     | ADD `Happy Number`     |
| 2024.04.16     | 149 / 150     | ADD `Plus One`     |

##### Plus One

:::spoiler
![VS--YouTube-PlusOne-Leetcode66-Python-8’05”](https://hackmd.io/_uploads/r1jWk0qxR.png)

:::

##### Multiply strings

:::spoiler
```
class Solution:
    def multiply(self, num1: str, num2: str) -> str:
        if "0" in [num1, num2]:
            return "0"

        res = [0] * (len(num1) + len(num2))
        num1, num2 = num1[::-1], num2[::-1]
        print("num1,num2:",num1,num2)
        for i1 in range(len(num1)):
            for i2 in range(len(num2)):
                print("d1xd2:",int(num1[i1]),int(num2[i2]))
                digit = int(num1[i1]) * int(num2[i2])
                res[i1 + i2] += digit
                res[i1 + i2 + 1] += res[i1 + i2] // 10
                res[i1 + i2] = res[i1 + i2] % 10

        res, beg = res[::-1], 0
        while beg < len(res) and res[beg] == 0:
            beg += 1
        res = map(str, res[beg:])
        return "".join(res)
```        
:::

:::spoiler
### with explain
```python
class Solution:
    def multiply(self, num1: str, num2: str) -> str:
        if "0" in [num1, num2]:
            return "0"

        # max len : 999 x 999 = 998 001
        res = [0] * (len(num1) + len(num2))
        # from 0 to process 
        num1, num2 = num1[::-1], num2[::-1]
        print("num1,num2:",num1,num2)
        for i1 in range(len(num1)):
            for i2 in range(len(num2)):
                print("d1xd2:",int(num1[i1]),int(num2[i2]))
                # digit1 x digit2  
                digit = int(num1[i1]) * int(num2[i2])
                # 累加至 res 的 current digit
                res[i1 + i2] += digit
                # 進位 
                res[i1 + i2 + 1] += res[i1 + i2] // 10
                # update current digit 
                res[i1 + i2] = res[i1 + i2] % 10

        res, beg = res[::-1], 0
        # search for non-zero digit
        while beg < len(res) and res[beg] == 0:
            beg += 1
        # trasfer all int to str     
        res = map(str, res[beg:])
        # string list to string 
        return "".join(res)

        
```
:::


