03 2017 档案

摘要: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 阅读(145) 评论(0) 推荐(0)
摘要:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another char... 阅读全文
posted @ 2017-03-27 23:46 xiejunzhao 阅读(231) 评论(0) 推荐(0)
摘要:Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them... 阅读全文
posted @ 2017-03-24 22:36 xiejunzhao 阅读(207) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;/** * 插入排序 * **/namespace Algorithm { class InsertionSort where T:IComparable{ //插入排序 s... 阅读全文
posted @ 2017-03-23 23:31 xiejunzhao 阅读(242) 评论(0) 推荐(0)
摘要:int l = Int32.MaxValue;//2147483647int r = Int32.MaxValue;//2147483647Console.WriteLine((l + r)/2);//-1Console.WriteLine(l + (r - l) / 2);//2147483647null 阅读全文
posted @ 2017-03-23 23:20 xiejunzhao 阅读(372) 评论(0) 推荐(0)
摘要:实现:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;/** * 二叉搜索树 * 一棵二叉搜索树是满足以下条件的二叉树 * 1.所有左节点的值都小于本节点的值 * 2.所有节点的值都小于右节点的值 **/namespace A... 阅读全文
posted @ 2017-03-20 00:09 xiejunzhao 阅读(500) 评论(0) 推荐(0)
摘要:方法如下:如果x没有子节点,或者只有一个孩子,直接将x切下如果x有两个孩子,我们有其右子树中的最小值替换x,然后将左子树中的这一最小值切掉/*** 删除节点* */public BSTreeNode Delete(BSTreeNode t ,BSTreeNode x) { if (x == null) return Root; BSTreeNode root = t; BSTreeNode old... 阅读全文
posted @ 2017-03-19 22:41 xiejunzhao 阅读(1101) 评论(0) 推荐(0)
摘要:前驱结点:节点val值小于该节点val值并且值最大的节点 后继节点:节点val值大于该节点val值并且值最小的节点 二叉树的节点val值是按照二叉树中序遍历顺序连续设定。前驱结点如图4的前驱结点是32的前驱结点是16的前驱结点是5后继节点7的后继结点是85的后继节点是62的后继节点是3前驱节点若一个节点有左子树,那么该节点的前驱节点是其左子树中val值最大的节点(也就是左子树中所谓的rightMo... 阅读全文
posted @ 2017-03-19 12:29 xiejunzhao 阅读(8133) 评论(0) 推荐(2)
摘要:Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be larger ... 阅读全文
posted @ 2017-03-15 23:01 xiejunzhao 阅读(174) 评论(0) 推荐(0)
摘要:参考资料:http://blog.csdn.net/v_july_v/article/details/7041827#t10 3.3.6 基于《最大长度表》与基于《next 数组》等价 我们已经知道,利用next 数组进行匹配失配时,模式串向右移动 j - next [ j ] 位,等价于已匹配字符数 - 失配字符的上一位字符所对应的最大长度值。原因是:j 从0开始计数,那么当数到失配字符时... 阅读全文
posted @ 2017-03-12 12:07 xiejunzhao 阅读(244) 评论(0) 推荐(0)
摘要:In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the poisoning tim... 阅读全文
posted @ 2017-03-11 22:06 xiejunzhao 阅读(152) 评论(0) 推荐(0)
摘要:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra spac... 阅读全文
posted @ 2017-03-11 12:40 xiejunzhao 阅读(128) 评论(0) 推荐(0)
摘要:We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number is higher or low... 阅读全文
posted @ 2017-03-09 23:53 xiejunzhao 阅读(205) 评论(0) 推荐(0)
摘要:Node.JS 文件读写,把Sheet图集数据转换为龙骨动画图集数据var fs = require("fs")var readline = require("readline");var rl = readline.createInterface({ input:process.stdin, output:process.stdout});var path = undefined;... 阅读全文
posted @ 2017-03-08 22:05 xiejunzhao 阅读(383) 评论(0) 推荐(0)
摘要:class Program { static double size = 2.443438914027149; static void Main(string[] args) { if (!System.IO.Directory.Exists("Img")){ System.IO.Directory... 阅读全文
posted @ 2017-03-07 22:15 xiejunzhao 阅读(291) 评论(0) 推荐(0)
摘要:Determine whether an integer is a palindrome. Do this without extra space.题意:判断一个数字是否为回文数如何取得一个Integer的最高位?假设x = 688答:x / mask. 设置一个和x位数一样的mask,mask = 100,然后用x/mask,表示x里面有几个mask,即是最高位数字. 688里有6个100,即为... 阅读全文
posted @ 2017-03-06 22:19 xiejunzhao 阅读(189) 评论(0) 推荐(0)
摘要:Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.http://bookshadow.com/weblog/2014/12/30/leetcode-factorial-trailing-zeroes/题... 阅读全文
posted @ 2017-03-03 22:37 xiejunzhao 阅读(244) 评论(0) 推荐(0)
摘要:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty() --... 阅读全文
posted @ 2017-03-02 22:54 xiejunzhao 阅读(158) 评论(0) 推荐(0)
摘要:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the top element.empty() -- Return whether ... 阅读全文
posted @ 2017-03-02 22:53 xiejunzhao 阅读(272) 评论(0) 推荐(0)
摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with con... 阅读全文
posted @ 2017-03-01 23:41 xiejunzhao 阅读(132) 评论(0) 推荐(0)
摘要:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?题意:计算杨辉三角的某一行,要求空间复杂度为O(k)pu... 阅读全文
posted @ 2017-03-01 23:40 xiejunzhao 阅读(83) 评论(0) 推荐(0)