- 博客(5)
- 收藏
- 关注
原创 面试题 04.03. 特定深度节点链表(层次遍历)
class Solution { public: vector<ListNode*> listOfDepth(TreeNode* tree) { queue<TreeNode*> q; q.push(tree); vector<ListNode*> ret; while(!q.empty()){ int size = q.size(); ListNod.
2021-02-03 20:57:21 85
原创 面试题 01.09. 字符串轮转
class Solution { public: bool isFlipedString(string s1, string s2) { return s1.size()==s2.size()&&(s1+s1).find(s2)!=-1; } };
2021-02-01 23:00:38 66 1
原创 面试题 08.10. 颜色填充
void dfs(int** image, int rowSize, int colSize, int r, int c, int newColor, int oldColor){ if (r<0 || c<0 || r>=rowSize || c>=colSize || image[r][c] == newColor || image[r][c] != oldColor ){ return; } image[r][c] = newColor;
2021-01-31 22:40:38 146
原创 剑指offer55-Ⅱ. 平衡二叉树
leetcode刷题剑指offer55-Ⅱ. 平衡二叉树 剑指offer55-Ⅱ. 平衡二叉树 #define max(a,b) (a>b?a:b) int depth(struct TreeNode* root){ if(!root) return 0; int left = depth(root->left); if(left==-1) return -1; int right = depth(root->right); if(right==
2021-01-30 21:50:44 52
原创 LeetCode 第5题 最长回文子串
题目:给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为1000。 示例 1: 输入: “babad” 输出: “bab” 注意: "aba"也是一个有效答案。 示例 2: 输入: “cbbd” 输出: “bb” 以下是两种Python的解法代码: #第一种方法 class Solution: def longestPalindrome(self, s): ...
2018-10-10 23:32:58 158
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人