自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 收藏
  • 关注

原创 LeetCode字符串相乘

class Solution {public: string multiply(string num1, string num2) { vector<int> res,n1,n2; res.resize(num1.size() + num2.size() - 1); for (int i = num1.size() - 1; i >= 0; i--) { int num = num1[i] .

2020-07-24 15:38:41 209

原创 LeetCode接雨水

class Solution {public: int trap(vector<int>& height) { int res = 0; int maxaddr = 0; for (int i = 0; i < height.size(); i++) { if (height[i] > height[maxaddr]) { .

2020-07-24 10:46:58 187

原创 LeetCode 电话号码的字母组合

class Solution {private:vector<string>map={"abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};vector<string> res;void func(string digits,int index,string s){ if(index==digits.size()) { res.push_back(s); return ; .

2020-07-23 16:22:54 217

原创 LeetCode 有效的数独

class Solution {public: bool isValidSudoku(vector<vector<char>>& board) { vector<vector<int>> rows(9,vector<int>(9,0)); vector<vector<int>> cols(9,vector<int>(9,0)); vector&l.

2020-07-23 14:42:55 191

原创 LeetCode两两交换链表的节点

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* swapPairs(ListNode* head) { if(!head) { .

2020-07-21 17:52:02 103

原创 LeetCode实现strstr的功能

class Solution {public: int strStr(string haystack, string needle) { if(needle=="") return 0; if(needle.size()>haystack.size()) return -1; for(int i=0;i<haystack.size()-needle.size()+1;i++) { .

2020-07-21 17:49:59 129

原创 LeetCode两两交换链表中的节点

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* swapPairs(ListNode* head) { if(!head) { .

2020-07-21 14:25:39 88

原创 LeetCode有效的括号

有效的括号class Solution {public: bool isValid(string s) { list<char> stack; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') { stack.push_back(s[i]); }

2020-07-20 09:44:53 101

原创 LeetCode删除链表的倒数第 n 个节点,并且返回链表的头结点

给定一个链表,删除链表的倒数第 n 个节点,并且返回链表的头结点。/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* removeNthFromEnd(ListNod

2020-07-20 09:18:42 243

原创 LeetCode

class Solution {public: int myAtoi(string str) { string s1; int i = 0; while (str[0] == ' ') str = str.substr(1, str.size() - 1); i = 0; while (isdigit(str[i]) || str[i] == '+' || str[i] == '-') .

2020-07-19 13:07:51 93

原创 LeetCode

整数反转我写的:class Solution {public: int reverse(int x) { deque<int> num; int idx = 10; while (x) { num.push_back(x % idx); x = x / 10; } int res=0; while (num.front()

2020-07-19 10:34:01 105

原创 LeetCode

Z字形变换class Solution {public: string convert(string s, int numRows) { if (numRows == 1) { return s; } string res; string* res1 = new string[numRows]; for (int i = 0; i < s.size(

2020-07-19 09:31:10 98

原创 LeetCode

运行的结果没错,但是提示超出时间限制了。。。。我太难了class Solution {public: bool isSym(string s, int i, int j) { while (j >= i) { if (s[i] != s[j]) return false; i++; j--; } return true; } string longestPalindrome(string s) { int begin = 0; i.

2020-07-19 08:48:27 92

原创 LeetCode第一第二题,持续更新

第一题class Solution {public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> res; for(int i=0;i<nums.size();i++) { for(int j=i+1;j<nums.size();j++) {

2020-07-18 18:46:09 204

原创 设计模式:策略模式

策略模式/*策略模式策略模式是对算法的封装 当调用算法的时候 可以使用C++的多态性, 来使用具体的算法,实现算法互换 适用于多if else,而条件的种类未来可能还会增加提高了相似算法的增加与删除的灵活性*/#include<iostream>using namespace std;class BaseStategy //抽象基类{public: BaseStategy() {}; virtual ~BaseStategy() {}; virtu

2020-07-06 10:32:41 185

原创 二叉树

二叉树的先序遍历,后续遍历,中序遍历,层序遍历#include <iostream>using namespace std;#include<deque>template <class T>class TreeNode{public: TreeNode<T>* pLeft; TreeNode<T>* pRight; T data; TreeNode(T t) :data(t), pLeft(NULL), pRight(NULL

2020-07-04 22:40:57 99

原创 C++实现基数排序

C++基数排序#include <iostream>#include <list>using namespace std;int maxdigit(int data[],int n){ int d = 1; int p = 10; for (int i = 0; i < n; i++) { while (data[i] >= p) { p *= 10; ++d; } } return d;}void RadixSort(

2020-07-04 17:45:56 282

原创 循环队列

循环队列#pragma once#include <iostream>using namespace std;template<class T>class Queue{private: T* queue; int capcity; int front, rear;public: Queue(int cap); ~Queue(); bool isEmpty(); T Front(); T Rear(); void pop(); void Push(T

2020-07-03 17:29:50 108

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除