随笔分类 - 第三期Week1——模拟专题 && 背包问题后三讲
摘要:1 //1与2交替出现,从下标2开始 2 class Solution 3 { 4 public: 5 int magicalString(int n) 6 { 7 string s = "122"; 8 for(int i = 2,k = 1;i < n;i ++,k = 3 - k) 9 { 1
阅读全文
摘要:1 class Solution 2 { 3 public: 4 string convertToBase7(int num) 5 { 6 string res; 7 bool a = true; 8 if(num < 0) num = -num,a = false; 9 while(num) 10
阅读全文
摘要:1 // 统计个数,相同位置相同数字的个数 >A的个数 2 // 不同位置相同数字的个数 >B的个数 3 class Solution 4 { 5 public: 6 string getHint(string secret, string guess) 7 { 8 int n = secret.s
阅读全文
摘要:1 class Solution 2 { 3 public: 4 bool isUgly(int num) 5 { 6 if (num == 0) return false; 7 while (num % 2 == 0) num /= 2; 8 while (num % 3 == 0) num /=
阅读全文
摘要:1 // "/a//b////c/d//././/.." 2 class Solution 3 { 4 vector<string> res; 5 void spilt(string s,char c,vector<string> &res) 6 { 7 istringstream iss(s);
阅读全文
摘要:1 class Solution 2 { 3 public: 4 string addBinary(string a, string b) 5 { 6 if(a.size() < b.size()) swap(a,b); 7 int C = 0;//进位 8 int m = a.size(),n =
阅读全文
摘要:1 class Solution 2 { 3 vector<int> ans; 4 public: 5 vector<int> spiralOrder(vector<vector<int>>& matrix) 6 { 7 if(matrix.size() == 0) return {}; 8 int
阅读全文
摘要:1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), next(NULL) {} 7 * };
阅读全文
摘要:1 //用到了贪心思想 2 class Solution 3 { 4 public: 5 int a[13] = {1,4,5,9,10,40,50,90,100,400,500,900,1000}; 6 string b[13] = {"I","IV","V","IX","X","XL","L",
阅读全文

浙公网安备 33010602011771号