10 2017 档案

摘要:Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively.Substring... 阅读全文
posted @ 2017-10-17 23:02 xiejunzhao 阅读(1136) 评论(0) 推荐(0)
摘要:Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input: "tree" Output: "eert" Explanation: 'e' appears twice while 'r' and 't' both appear once. So 'e' must... 阅读全文
posted @ 2017-10-17 00:25 xiejunzhao 阅读(194) 评论(0) 推荐(0)
摘要:Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest possible length of a (c... 阅读全文
posted @ 2017-10-15 21:55 xiejunzhao 阅读(183) 评论(0) 推荐(0)
摘要:let co = require("co");//模拟异步操作let wait = (t) => { return new Promise((resolve, reject) => { console.log("start:" + t); setTimeout(() => { console.log(t); resolv... 阅读全文
posted @ 2017-10-14 22:55 xiejunzhao 阅读(1381) 评论(0) 推荐(0)
摘要:Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by ... 阅读全文
posted @ 2017-10-13 22:30 xiejunzhao 阅读(146) 评论(0) 推荐(0)
摘要:Given a list of directory info including directory path, and all the files with contents in this directory, you need to find out all the groups of duplicate files in the file system in terms of their ... 阅读全文
posted @ 2017-10-11 20:25 xiejunzhao 阅读(348) 评论(0) 推荐(0)
摘要:Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (includi... 阅读全文
posted @ 2017-10-11 20:25 xiejunzhao 阅读(294) 评论(0) 推荐(0)
摘要:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums = [1,... 阅读全文
posted @ 2017-10-11 20:22 xiejunzhao 阅读(116) 评论(0) 推荐(0)
摘要:Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.Note: The length of path between two nodes is re... 阅读全文
posted @ 2017-10-10 20:33 xiejunzhao 阅读(189) 评论(0) 推荐(0)
摘要:Implement a MapSum class with insert, and sum methods.For the method insert, you'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key... 阅读全文
posted @ 2017-10-10 20:33 xiejunzhao 阅读(354) 评论(0) 推荐(0)
摘要:Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.Example 1:Input: 5 Output: True Explanation: The binary representation o... 阅读全文
posted @ 2017-10-08 22:08 xiejunzhao 阅读(197) 评论(0) 推荐(0)
摘要:Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrou... 阅读全文
posted @ 2017-10-08 21:58 xiejunzhao 阅读(1578) 评论(0) 推荐(0)
摘要:Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1.For example, with A = "abcd" and B = "cdabcdab".Return... 阅读全文
posted @ 2017-10-04 23:09 xiejunzhao 阅读(209) 评论(0) 推荐(0)