十一月的may
十一月的may
全部文章
题解
归档
标签
去牛客网
登录
/
注册
枫的博客
全部文章
/ 题解
(共35篇)
题解 | #在二叉树中找到两个节点的最近公共祖先#
class Solution { public: /** * * @param root TreeNode类 * @param o1 int整型 * @param o2 int整型 * @return int整型 */ ...
2021-08-17
0
383
题解 | #最长无重复子数组#
class Solution { public: /** * * @param arr int整型vector the array * @return int整型 */ int maxLength(vector<int>& ...
2021-08-17
0
352
题解 | #求二叉树的层序遍历#
class Solution { public: /** * * @param root TreeNode类 * @return int整型vector<vector<>> */ vector<vector&l...
2021-08-17
0
507
题解 | #二分查找-II#
int search(vector<int>& nums, int target) { int index=nums.size(); int left=0,right=nums.size()-1; while(left<=ri...
2021-08-17
0
459
题解 | #反转链表#
class Solution { public: ListNode* ReverseList(ListNode* pHead) { /*ListNode *pre=NULL; while(pHead) { ListNod...
2021-08-17
0
409
题解 | #判断链表中是否有环#
class Solution { public: bool hasCycle(ListNode *head) { //第一种解法:每次让一个结点的next指向自己,如果有环,最终只剩一个结点成环 /*while(head&&head->n...
2021-08-17
0
450
题解 | #单词倒排#
C++简单题解:使用一个dp数组表示该位置的数需要右移的位数,用vector保存需要放置*的位置。 #include<iostream> #include<cstring> #include<vector> using namespace std; bool i...
2021-07-29
0
433
题解 | #输入整型数组和排序标识,对其元素按照升序或降序进行排序#
C++简单题解:使用快排进行排序:选定一个基准数,从后往左找小于基准数的数,从前往后找大于基准数的数,直到两个指针碰头,最后基准数左右两边分别为大于、小于基准数的数。 #include<iostream> using namespace std; int quick(int a[],i...
2021-07-29
0
427
题解 | #字符统计#
c++简单题解: #include<iostream> using namespace std; int main() { string s; while(cin>>s) { int a[150]={0}, m=0; ...
2021-07-28
14
746
题解 | #Redraiment的走法#
c++简单题解:用dp[i]表示从第一个数到dp[i]最多走的步数。 #include<iostream> #include<vector> using namespace std; int main() { int n; while(cin>>...
2021-07-28
0
582
首页
上一页
1
2
3
4
下一页
末页