- 博客(11)
- 收藏
- 关注
原创 关于scrolltop兼容性问题
最近工作时修复topbar 渐变色问题的bug,发现 document.body.scrollTop 取值一直为0 这里给出三个解决方案: 解决方案1:let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; 解决DTD问题 htt
2017-10-28 00:08:09 330
原创 Average of Levels in Binary Tree
题意:求每一层的数据平均值,放到Vector里 思路:层序遍历,没啥难的 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), le
2017-10-08 21:59:10 424
原创 Two Sum IV - Input is a BST
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ clas
2017-10-08 20:17:17 286
原创 Invert Binary Tree
反转二叉树,没仔细看题,层序遍历的思想,写完WA了,一看错误数据,尴尬的反转错了 TreeNode* invertTree(TreeNode* root) { queue q; TreeNode* newroot = root; q.push(root); while(!q.empty()){
2017-10-07 23:31:08 207
原创 BinaryTree C++
最近刷LeetCode回顾二叉树相关知识,于是想自己先把二叉树的建立以及基本操作实现一遍。 #include #include #include #include using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x)
2017-10-07 17:52:50 460
原创 Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array.
2017-10-07 12:21:35 198
原创 Single Number
O(n)的时间复杂的没有想出来,看了Discuss. int singleNumber(int* nums, int numsSize) { int num = 0; for(int i=0 ;i<numsSize; i++){ num ^= nums[i]; } return num; }
2017-10-07 00:27:18 191
原创 Vue实现简单ToDoList
一个简单的TodoList 挂个链接点这里 注意:回车自动添加,注意先输入要做的事,再输入时间,空格隔开 <input id="todo" class="form-control" v-model="newTodo" v-on:keyup.enter="addNewTodo
2017-10-04 09:58:10 543
原创 Island Perimeter
勉强算一道搜索吧。。 class Solution { public: int islandPerimeter(vector>& grid) { int row = grid.size(); int col = grid[0].size(); int sum = 0; for(int i=0 ;i<row ; i++){
2017-10-02 10:40:47 164
原创 (回顾)水池数目 &&最少步数
刷LeetCode刷到搜索,想先在nyoj上回顾两道之前做过的。 # include # include # include using namespace std; int n,m; int map[110][110]; int fx[4][2]={0,1,0,-1,1,0,-1,0}; void BFS(int x,int y){ int nx,ny; for(int
2017-10-02 10:04:28 224
原创 Baseball Game
/** * @param {string[]} ops * @return {number} */ var calPoints = function(ops) { var arr = []; for(var i =0 ;i<ops.length ;i++){ if(ops[i] == 'D'){ var leng
2017-10-01 13:35:42 269
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人