上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 27 下一页
摘要: /*** 广度优先遍历* **/public void BreadthFirstTreeWalk(BSTreeNode root, Action> func) { if (root == null) { return; } List> processQueue = new List>(); processQueue.Add(root); BSTreeNode current; while (pr... 阅读全文
posted @ 2017-04-11 23:52 xiejunzhao 阅读(588) 评论(0) 推荐(0)
摘要: /*** 非递归 中序遍历* **/public void InOrderTreeWalk(BSTreeNode root, Action> func) { if (root == null) { return; } Stack> stack = new Stack>((int)(2 * Math.Log(Count + 1))); BSTreeNode current = root; whil... 阅读全文
posted @ 2017-04-11 23:50 xiejunzhao 阅读(295) 评论(0) 推荐(0)
摘要: Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.p... 阅读全文
posted @ 2017-04-11 22:55 xiejunzhao 阅读(198) 评论(0) 推荐(0)
摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one 2, then o... 阅读全文
posted @ 2017-04-08 23:29 xiejunzhao 阅读(126) 评论(0) 推荐(0)
摘要: Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5题意:移除链表中指定val的元素注意:考虑删除节点在尾部,以及连续删除两... 阅读全文
posted @ 2017-04-05 00:12 xiejunzhao 阅读(207) 评论(0) 推荐(0)
摘要: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid but ... 阅读全文
posted @ 2017-04-04 11:01 xiejunzhao 阅读(163) 评论(0) 推荐(0)
摘要: We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.Now, given an integer n, write a function that returns true when it is a perfect ... 阅读全文
posted @ 2017-04-04 10:08 xiejunzhao 阅读(197) 评论(0) 推荐(0)
摘要: 博客设置 -> 页面定制CSS代码填入以下样式表/*Original style from softwaremaniacs.org (c) Ivan Sagalaev */.hljs { display: block; padding: 0.5em; background: #F0F0F0;}.hljs,.hljs-subst,.hljs-tag .hljs-title,.lisp .hljs... 阅读全文
posted @ 2017-04-02 00:01 xiejunzhao 阅读(386) 评论(0) 推荐(0)
摘要: Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断一个链表是否为回文串思路:1.找到中间点,2.反转后半部分链表,3.判断前半部分与后半部分是否相同/** * Definition for singly-linked ... 阅读全文
posted @ 2017-04-01 23:30 xiejunzhao 阅读(160) 评论(0) 推荐(0)
摘要: Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Examples:p... 阅读全文
posted @ 2017-03-30 00:13 xiejunzhao 阅读(144) 评论(0) 推荐(0)
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 27 下一页