随笔分类 - LeetCode
摘要:"题目" c++ class Solution { public: string longestCommonPrefix(vector& strs) { if(strs.size()==0) return ""; int i=0; string ans=""; while(true) { if(i=
阅读全文
摘要:"题目" c++
阅读全文
摘要:"题目" class Solution { public: int v[7]={1,5,10,50,100,500,1000}; string s[7]={"I","V","X","L","C","D","M"}; string intToRoman(int num) { string ans=""
阅读全文
摘要:"题目" class Solution { public: int s[10005]; int maxArea(vector& height) { int ans=0; int l=0; int r=height.size() 1; while(l
阅读全文
摘要:"题目" 大模拟 c++ class Solution { public: int dp[1005][1005]; bool ans; bool isMatch(string s, string p) { return judge(s,p,0,0); } bool judge(string s,st
阅读全文
摘要:"题目" c++ class Solution { public: int a[100005]; bool isPalindrome(int x) { if(x
阅读全文
摘要:"题目" c++ 多注意注意 class Solution { public: int myAtoi(string str) { int len = str.length(); int tag=0; int tag2=0; char tag3='x'; string num=""; for(int
阅读全文
摘要:"题目" c++ class Solution { public: int reverse(int x) { long long int ans=0; int tag=0; while(x) { long long int y =x%10; x/=10; if(y==0&&tag==0) conti
阅读全文
摘要:"题目" 算模拟题吧 class Solution { public: char a[1000][1000]; int tag[1000][1000]; string convert(string s, int numRows) { if(numRows==0||numRows==1) return
阅读全文
摘要:"题目" c++ 回文串,区间DP class Solution { public: int dp[1005][1005]; string longestPalindrome(string s) { int len = s.length(); int ii,jj; int m=0; for(int
阅读全文
摘要:"题目" c++
阅读全文
摘要:"题目" class Solution { public: vector twoSum(vector& nums, int target) { vector res; for(int i=0;i
阅读全文
摘要:"题目" 二分 一不小心耗时超过100%的c++解决方案。哈哈哈
阅读全文
摘要:"题目" c++
阅读全文
摘要:"题目" 煞笔题目,怪不得那么多人diss 两层for循环,它还疯狂卡精度,double的精度不够,必须long double
阅读全文
摘要:"题目" 实现一个缓存机制。很多人的写法都是使用HashTable, Map,Dictionary 或者别的工具。 但是我,自己硬核手写了一个可插入删除的AVL树,并且把这道题目给过了 代码实在有点偏长,以后再重构代码。 过程中Wa了很多次,最后一次的AC的感觉,真是找到以前比赛时候的感觉。
阅读全文
摘要:"LeetCode 150 Evaluate Reverse Polish Notation" 后缀表达式,利用栈就可以轻松计算 c++ class Solution { public: int stack[10005]; int pos=0; int evalRPN(vector& tokens)
阅读全文
摘要:LeetCode 148 Sort List 排序, 我使用了三种排序: 手写快排: 48ms C++模板快排: 48ms 堆排序:52ms c++:
阅读全文
浙公网安备 33010602011771号