Fork me on GitHub

07 2017 档案

摘要:Imagine you have a special keyboard with the following keys: Key 1: (A): Prints one 'A' on screen. Key 2: (Ctrl-A): Select the whole screen. Key 3: (C 阅读全文
posted @ 2017-07-31 18:47 hellowOOOrld 阅读(943) 评论(0) 推荐(0)
摘要:Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Given a number n. You have to 阅读全文
posted @ 2017-07-30 11:47 hellowOOOrld 阅读(780) 评论(0) 推荐(1)
摘要:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou 阅读全文
posted @ 2017-07-25 17:35 hellowOOOrld 阅读(180) 评论(0) 推荐(0)
摘要:Note: This is an extension of House Robber. After robbing those houses on that street, the thief has found himself a new place for his thievery so tha 阅读全文
posted @ 2017-07-25 16:16 hellowOOOrld 阅读(302) 评论(0) 推荐(0)
摘要:In English, we have a concept called root, which can be followed by some other words to form another longer word - let's call this word successor. For 阅读全文
posted @ 2017-07-24 16:33 hellowOOOrld 阅读(492) 评论(0) 推荐(0)
摘要:Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are c 阅读全文
posted @ 2017-07-24 15:34 hellowOOOrld 阅读(422) 评论(0) 推荐(0)
摘要:You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow an 阅读全文
posted @ 2017-07-23 13:26 hellowOOOrld 阅读(719) 评论(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 n 阅读全文
posted @ 2017-07-23 12:45 hellowOOOrld 阅读(375) 评论(0) 推荐(0)
摘要:Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may a 阅读全文
posted @ 2017-07-18 21:01 hellowOOOrld 阅读(152) 评论(0) 推荐(0)
摘要:Given the running logs of n functions that are executed in a nonpreemptive single threaded CPU, find the exclusive time of these functions. Each funct 阅读全文
posted @ 2017-07-16 19:17 hellowOOOrld 阅读(330) 评论(0) 推荐(0)
摘要:Given an array consisting of n integers, find the contiguous subarray whose length is greater than or equal to k that has the maximum average value. A 阅读全文
posted @ 2017-07-16 13:50 hellowOOOrld 阅读(761) 评论(0) 推荐(0)
摘要:Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ? s. If there isn't 阅读全文
posted @ 2017-07-16 12:14 hellowOOOrld 阅读(214) 评论(0) 推荐(0)
摘要:Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. Example 1: Example 2: 思路: 将0改为-1,将原题目改成求最大连续区间,区间 阅读全文
posted @ 2017-07-15 22:43 hellowOOOrld 阅读(142) 评论(0) 推荐(0)
摘要:https://discuss.leetcode.com/topic/91430/c-clean-solution-answers-to-follow-upGiven a list of directory info including directory path, and all the fil 阅读全文
posted @ 2017-07-13 09:35 hellowOOOrld 阅读(435) 评论(0) 推荐(0)
摘要:Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assum 阅读全文
posted @ 2017-07-12 21:56 hellowOOOrld 阅读(208) 评论(0) 推荐(0)
摘要:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacen 阅读全文
posted @ 2017-07-11 23:01 hellowOOOrld 阅读(156) 评论(0) 推荐(0)
摘要:Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may ass 阅读全文
posted @ 2017-07-11 22:43 hellowOOOrld 阅读(176) 评论(0) 推荐(0)
摘要:The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total num 阅读全文
posted @ 2017-07-10 21:38 hellowOOOrld 阅读(138) 评论(0) 推荐(0)
摘要:Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. Note: All letters in hexadec 阅读全文
posted @ 2017-07-10 20:53 hellowOOOrld 阅读(180) 评论(0) 推荐(0)
摘要:Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable xand it 阅读全文
posted @ 2017-07-09 12:01 hellowOOOrld 阅读(686) 评论(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: 思路: 层次遍历。 阅读全文
posted @ 2017-07-09 11:56 hellowOOOrld 阅读(628) 评论(0) 推荐(0)
摘要:Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each elemen 阅读全文
posted @ 2017-07-08 21:52 hellowOOOrld 阅读(180) 评论(0) 推荐(0)
摘要:Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 阅读全文
posted @ 2017-07-07 14:23 hellowOOOrld 阅读(178) 评论(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 twi 阅读全文
posted @ 2017-07-06 21:27 hellowOOOrld 阅读(214) 评论(0) 推荐(0)
摘要:Given a list of 24-hour clock time points in "Hour:Minutes" format, find the minimum minutes difference between any two time points in the list. Examp 阅读全文
posted @ 2017-07-06 14:26 hellowOOOrld 阅读(151) 评论(0) 推荐(0)
摘要:Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: 思路: 模拟手工加法过程,用carry表示进位。 第一个是自己写的,比较啰嗦。 第二 阅读全文
posted @ 2017-07-05 22:53 hellowOOOrld 阅读(250) 评论(0) 推荐(0)
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example,Given nums = [0, 1, 阅读全文
posted @ 2017-07-05 17:29 hellowOOOrld 阅读(119) 评论(0) 推荐(0)
摘要:Find the sum of all left leaves in a given binary tree. Example: 阅读全文
posted @ 2017-07-04 16:49 hellowOOOrld 阅读(88) 评论(0) 推荐(0)
摘要:转载自:http://www.cnblogs.com/haore147/p/3618930.html 1. 安装两个软件 1 2 1. git的命令行程序--git for windows:http://git-scm.com/download/win 2. git的GUI程序--tortoiseg 阅读全文
posted @ 2017-07-03 21:11 hellowOOOrld 阅读(273) 评论(0) 推荐(0)
摘要:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the rans 阅读全文
posted @ 2017-07-03 20:51 hellowOOOrld 阅读(162) 评论(0) 推荐(0)
摘要:Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n  阅读全文
posted @ 2017-07-03 10:07 hellowOOOrld 阅读(165) 评论(0) 推荐(0)
摘要:You are given several logs that each log contains a unique id and timestamp. Timestamp is a string that has the following format: Year:Month:Day:Hour: 阅读全文
posted @ 2017-07-02 19:54 hellowOOOrld 阅读(444) 评论(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: Example 2: 思路: 类似于二分查找。 阅读全文
posted @ 2017-07-02 12:06 hellowOOOrld 阅读(418) 评论(0) 推荐(0)
摘要:In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no element appears in its original position. There's 阅读全文
posted @ 2017-07-02 11:45 hellowOOOrld 阅读(727) 评论(0) 推荐(0)
摘要:Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element i 阅读全文
posted @ 2017-07-01 22:43 hellowOOOrld 阅读(103) 评论(0) 推荐(0)
摘要:Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The l 阅读全文
posted @ 2017-07-01 12:25 hellowOOOrld 阅读(224) 评论(0) 推荐(0)