摘要:
题目:Given a linked list, determine if it has a cycle in it.思路:对于判断链表是否有环,方法很简单,用两个指针,一开始都指向头结点,一个是快指针,一次走两步,一个是慢指针,一次只走一步,当两个指针重合时表示存在环了。fast先进入环,在slow... 阅读全文
摘要:
一、pointer-events1.元素加上pointer-events:none后,在js中加点击事件不好使原因:pointer-events:none关闭所有点击事件,包括js总的解决:删掉该属性2.移动端开发,页末尾的按键点击不好使原因:为了适配大屏幕,下一页有元素图片切得比较大,当用户滑到上... 阅读全文
摘要:
今天做项目中偶然误把元素加上了pointer-events属性,结果导致后来在js中给该元素加点击事件不能用,检查了半天才发现是这个属性的问题。之前没有好好研究,于是决定仔细研究一下。一、定义及语法根据MDN上的解释如下:CSS属性pointer-events允许作者控制特定的图形元素在何时成为属性... 阅读全文
摘要:
本文转载自http://www.zhangxinxu.com/wordpress/?p=5019一、IE和Chrome等浏览器与zoom还在几年前,zoom还只是IE浏览器自己私有的玩具,但是,现在,除了FireFox浏览器,其他,尤其Chrome和移动端浏览器已经很好支持zoom属性了:zoom的... 阅读全文
摘要:
题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a sing... 阅读全文
摘要:
题目:Sort a linked list using insertion sort.思路:插入排序是一种O(n^2)复杂度的算法,基本想法相信大家都比较了解,就是每次循环找到一个元素在当前排好的结果中相对应的位置,然后插进去,经过n次迭代之后就得到排好序的结果了。了解了思路之后就是链表的基本操作了... 阅读全文
摘要:
题目:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not ... 阅读全文
摘要:
题目:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the or... 阅读全文
摘要:
题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2-... 阅读全文
摘要:
题目:Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For e... 阅读全文
摘要:
题目:Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL... 阅读全文
摘要:
题目:Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.思路... 阅读全文
摘要:
题目:Sort a linked list inO(nlogn) time using constant space complexity.思路:nlogn的排序有快速排序、归并排序、堆排序。双向链表用快排比较适合,堆排序也可以用于链表,单向链表适合用归并排序。/** * Definition fo... 阅读全文
摘要:
题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your al... 阅读全文
摘要:
1.堆栈注意堆栈中的node需要暂存哪些数据,以及入口。举例:二维数组中找到用相邻字母组成的目标字符串。Givenboard=[ ['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E']]word="ABCCED", -> returnst... 阅读全文