---
# System prepended metadata

title: 6303. Separate the Digits in an Array
tags: [Leetcode]

---

<style>
    html, body, .ui-content {
    background: #222222;
    color: #00BFFF;
}
    /* 設定 code 模板 */
    .markdown-body code,
.markdown-body tt {
    background-color: #ffffff36;
}
.markdown-body .highlight pre,
.markdown-body pre {
    color: #ddd;
    background-color: #00000036;
}
.hljs-tag {
    color: #ddd;
}
.token.operator {
  background-color: transparent;
}    
/* 設定連結 */
a,
.open-files-container li.selected a {
    color: #89FFF8;
    
}
a:hover,
.open-files-container li.selected a:hover {
    color: #89FFF890;
}
   
</style>

###### tags: `Leetcode`

# 6303. Separate the Digits in an Array

###### Link : https://leetcode.com/contest/biweekly-contest-97/problems/separate-the-digits-in-an-array/

## 題目
將陣列裡的所以數字分開
## 程式碼
```cpp=
class Solution {
public:
    vector<int> separateDigits(vector<int>& nums) {
        vector<int> ans;
        for(int &it : nums){
            Solve(ans, it);
        }
        return ans;
    }
    void Solve(vector<int> &ans, int num){
        if(num <= 0) return;
        Solve(ans, num / 10);
        ans.push_back(num % 10);
        return;
    }
};
```

## Date 
### 2023/2/4