## [LeetCode C++实现]75. Sort Colors

class Solution {

public:

void sortColors(vector<int>& nums) {

sort(nums.begin(),nums.end());

}

};

Runtime: 0 ms, faster than 100.00% of C++ online submissions for Sort Colors.

Memory Usage: 8.3 MB, less than 64.12% o......

## [LeetCode C++实现]504. Base 7

class Solution {

public:

string convertToBase7(int num) {

if(num == 0) return "0";

string res;

if(num < 0)

{

res+='-';

num = -1 * num;

}

helper(res,num);

return res;

}

private:

void helper(string& res,int num) {

if(num == 0) return;

helper......

## [LeetCode C++实现]437. Path Sum III

/**

* Definition for a binary tree node.

* struct TreeNode {

* int val;

* TreeNode *left;

* TreeNode *right;

* TreeNode() : val(0), left(nullptr), right(nullptr) {}

* TreeNode(int x) : val(x),......

## [LeetCode C++实现]279. Perfect Squares

class Solution {

public:

int numSquares(int n) {

int sum = 0;

int num = n;

int cnt = 0;

while(num > 0) {

while(n >= sum + num && is_squares(num))

{

sum += num;

cnt += 1;

if(sum == n) return cnt;

}

num--;

}

return cnt;

}

private:

bool i......

C语言实现：

## [LeetCode C++实现]113. Path Sum II

/**

* Definition for a binary tree node.

* struct TreeNode {

* int val;

* TreeNode *left;

* TreeNode *right;

* TreeNode() : val(0), left(nullptr), right(nullptr) {}

* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

* TreeNo......

## [LeetCode C++实现]112. Path Sum

/**

* Definition for a binary tree node.

* struct TreeNode {

* int val;

* TreeNode *left;

* TreeNode *right;

* TreeNode() : val(0), left(nullptr), right(nullptr) {}

* TreeNode(int x) : val(x),......

## [LeetCode C++实现]470. Implement Rand10() Using Rand7()

// The rand7() API is already defined for you.

// i......

## [LeetCode C++实现]33. Search in Rotated Sorted Array

class Solution {

public:

int search(vector<int>& nums, int target) {

int l = 0,r = nums.size() - 1;

while(l <= r)

{

int mid = l + (r - l)/2;

if(nums[mid] == target) return......

1.系统调用

2.异常