随笔分类 -  Level 1

摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文
posted @ 2019-03-04 04:08 北叶青藤 阅读(154) 评论(0) 推荐(0)
摘要:Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are n 阅读全文
posted @ 2019-02-14 14:53 北叶青藤 阅读(122) 评论(0) 推荐(0)
摘要:The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calcul 阅读全文
posted @ 2017-01-03 09:58 北叶青藤 阅读(229) 评论(0) 推荐(0)
摘要:Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. For example,MovingAverage m = new Mo 阅读全文
posted @ 2017-01-03 06:49 北叶青藤 阅读(131) 评论(0) 推荐(0)
摘要:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] 阅读全文
posted @ 2016-12-30 10:29 北叶青藤 阅读(205) 评论(0) 推荐(0)
摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文
posted @ 2016-12-28 12:54 北叶青藤 阅读(216) 评论(0) 推荐(0)
摘要:Find the sum of all left leaves in a given binary tree. Example: 阅读全文
posted @ 2016-12-02 05:56 北叶青藤 阅读(229) 评论(0) 推荐(0)
摘要:Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Example 2: 阅读全文
posted @ 2016-11-20 09:42 北叶青藤 阅读(311) 评论(0) 推荐(0)
摘要:Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one celebrity. The definition of a celebrity is tha 阅读全文
posted @ 2016-08-06 11:19 北叶青藤 阅读(219) 评论(0) 推荐(0)
摘要:Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assum 阅读全文
posted @ 2016-08-06 05:51 北叶青藤 阅读(204) 评论(0) 推荐(0)
摘要:Missing Ranges You are given an inclusive range [lower, upper] and a sorted unique integer array nums, where all elements are in the inclusive range. 阅读全文
posted @ 2016-08-03 08:27 北叶青藤 阅读(194) 评论(0) 推荐(0)
摘要:You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time 阅读全文
posted @ 2016-08-01 12:21 北叶青藤 阅读(287) 评论(0) 推荐(0)
摘要:Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as s 阅读全文
posted @ 2016-08-01 04:41 北叶青藤 阅读(238) 评论(0) 推荐(0)
摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to 阅读全文
posted @ 2016-07-31 12:46 北叶青藤 阅读(246) 评论(0) 推荐(0)
摘要:Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example:Given n = 2, return 91. (The answer should be the 阅读全文
posted @ 2016-07-26 12:38 北叶青藤 阅读(172) 评论(0) 推荐(0)
摘要:Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio 阅读全文
posted @ 2016-07-26 10:37 北叶青藤 阅读(150) 评论(0) 推荐(0)
摘要:Given a non-negative number represented as a singly linked list of digits, plus one to the number. The digits are stored such that the most significan 阅读全文
posted @ 2016-07-26 00:25 北叶青藤 阅读(199) 评论(0) 推荐(0)
摘要:The size of the hash table is not determinate at the very beginning. If the total size of keys is too large (e.g. size >= capacity / 10), we should do 阅读全文
posted @ 2016-07-23 05:53 北叶青藤 阅读(366) 评论(0) 推荐(0)
摘要:There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following re 阅读全文
posted @ 2016-07-21 05:52 北叶青藤 阅读(204) 评论(0) 推荐(0)
摘要:Implement Queue by Two Stacks Implement Queue by Two Stacks Implement Queue by Two Stacks Implement the following operations of a queue using stacks. 阅读全文
posted @ 2016-07-19 05:41 北叶青藤 阅读(314) 评论(0) 推荐(0)