07 2017 档案

摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get the ... 阅读全文
posted @ 2017-07-31 23:05 xiejunzhao 阅读(238) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1] sumRange(0, 2) -> 1 sumRange(2, 5) -> -1 sumRange(0, 5)... 阅读全文
posted @ 2017-07-31 23:05 xiejunzhao 阅读(301) 评论(0) 推荐(0)
摘要:Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.You need to find th... 阅读全文
posted @ 2017-07-26 23:17 xiejunzhao 阅读(441) 评论(0) 推荐(0)
摘要:The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of o... 阅读全文
posted @ 2017-07-24 00:01 xiejunzhao 阅读(458) 评论(0) 推荐(0)
摘要:Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.Given ... 阅读全文
posted @ 2017-07-22 17:49 xiejunzhao 阅读(257) 评论(0) 推荐(0)
摘要:工作中时常需要把EXML代码中声明的组件编写到ts文件中,耗时耗力。因此编写一个小工具,自动生成组件声明代码。 工具代码如下:var fs = require("fs")var readline = require('readline');var rl = readline.createInterface(process.stdin, process.stdout); var input = ""... 阅读全文
posted @ 2017-07-22 00:35 xiejunzhao 阅读(771) 评论(0) 推荐(0)
摘要:Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:n is positive and will fit within the range of a 32-bit signed integer (n < 231).Example 1:Input:3Output:... 阅读全文
posted @ 2017-07-18 22:57 xiejunzhao 阅读(166) 评论(0) 推荐(0)
摘要:Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value.Example 1:Input: [1,12,-5,-... 阅读全文
posted @ 2017-07-16 18:24 xiejunzhao 阅读(278) 评论(0) 推荐(0)
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 0011100101111... 阅读全文
posted @ 2017-07-15 11:07 xiejunzhao 阅读(176) 评论(0) 推荐(0)
摘要:>>> '{0:.2f}'.format(1/3)'0.33'>>> '{0:b}'.format(10) #二进制'1010'>>> '{0:o}'.format(10) #八进制'12'>>> '{0:x}'.format(10) #16进制'a'>>> '{:,}'.format(12369132698) #千分位格式化'12,369,132,698 阅读全文
posted @ 2017-07-15 10:59 xiejunzhao 阅读(173) 评论(0) 推荐(0)
摘要:Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c.Example 1:Input: 5Output: TrueExplanation: 1 * 1 + 2 * 2 = 5Example 2:Input: 3Output:... 阅读全文
posted @ 2017-07-14 23:25 xiejunzhao 阅读(333) 评论(0) 推荐(0)
摘要:原帖:http://blog.csdn.net/louishao/article/details/57075531 最后一张图,就是正式修改系统环境的,点击Path,加上python2和python3的安装目录,和各自目录下的Scrips目录。配置完系统变量后,将python3安装目录下的python.exe复制一份,并改名为python3.exe完成操作之后,可以在命令行中输入python、py... 阅读全文
posted @ 2017-07-14 00:16 xiejunzhao 阅读(318) 评论(0) 推荐(0)
摘要:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by... 阅读全文
posted @ 2017-07-12 00:02 xiejunzhao 阅读(140) 评论(0) 推荐(0)
摘要:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.Example:... 阅读全文
posted @ 2017-07-09 23:23 xiejunzhao 阅读(293) 评论(0) 推荐(0)
摘要:Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.Example 1:Input: 3 / \ 9 20 / \ 15 7 Output: [3, 14.5, 11] Explanation: T... 阅读全文
posted @ 2017-07-09 18:06 xiejunzhao 阅读(280) 评论(0) 推荐(0)
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.题意:给一个二叉树,求出根节点到叶子节点(终端结点)的最短路径解法:使用BFS广度优... 阅读全文
posted @ 2017-07-08 23:32 xiejunzhao 阅读(145) 评论(0) 推荐(0)
摘要:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are:["1->2->5", "1->3"]# Definition for a binary tree ... 阅读全文
posted @ 2017-07-08 12:25 xiejunzhao 阅读(143) 评论(0) 推荐(0)
摘要:using System;using Newtonsoft.Json;using System.IO;using Newtonsoft.Json.Linq;namespace SQLHelper { class Program { static void Main(string[] args) { string strReadFilePath = @"data.json"; Stream... 阅读全文
posted @ 2017-07-02 18:27 xiejunzhao 阅读(2371) 评论(0) 推荐(0)
摘要:// #define USING_HASH_SET// ==++==// // Copyright (c) Microsoft Corporation. All rights reserved.// // ==--==/*============================================================**** Class: SortedSet****... 阅读全文
posted @ 2017-07-02 10:54 xiejunzhao 阅读(371) 评论(0) 推荐(0)
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Data.SqlClient;namespace SQLHelper { class Program { static void Main(strin... 阅读全文
posted @ 2017-07-02 10:52 xiejunzhao 阅读(388) 评论(0) 推荐(0)