11 2019 档案

摘要:Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally ident 阅读全文
posted @ 2019-11-21 13:00 xuan_abc 阅读(78) 评论(0) 推荐(0) 编辑
摘要:Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explan 阅读全文
posted @ 2019-11-21 12:48 xuan_abc 阅读(150) 评论(0) 推荐(0) 编辑
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2019-11-20 11:24 xuan_abc 阅读(114) 评论(0) 推荐(0) 编辑
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], 阅读全文
posted @ 2019-11-20 11:02 xuan_abc 阅读(156) 评论(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 @ 2019-11-20 10:41 xuan_abc 阅读(253) 评论(0) 推荐(0) 编辑
摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which 阅读全文
posted @ 2019-11-19 10:55 xuan_abc 阅读(133) 评论(0) 推荐(0) 编辑
摘要:Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endp 阅读全文
posted @ 2019-11-19 10:31 xuan_abc 阅读(90) 评论(0) 推荐(0) 编辑
摘要:Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except n 阅读全文
posted @ 2019-11-18 11:17 xuan_abc 阅读(140) 评论(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 @ 2019-11-18 10:58 xuan_abc 阅读(129) 评论(0) 推荐(0) 编辑
摘要:Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference room 阅读全文
posted @ 2019-11-18 07:23 xuan_abc 阅读(248) 评论(0) 推荐(0) 编辑
摘要:Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all mee 阅读全文
posted @ 2019-11-18 05:36 xuan_abc 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. Example:Assume that words = ["p 阅读全文
posted @ 2019-11-18 05:05 xuan_abc 阅读(124) 评论(0) 推荐(0) 编辑
摘要:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 阅读全文
posted @ 2019-11-18 03:55 xuan_abc 阅读(107) 评论(0) 推荐(0) 编辑
摘要:Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-white 阅读全文
posted @ 2019-11-17 12:34 xuan_abc 阅读(117) 评论(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 @ 2019-11-17 11:57 xuan_abc 阅读(134) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant d 阅读全文
posted @ 2019-11-17 10:00 xuan_abc 阅读(152) 评论(0) 推荐(0) 编辑
摘要:Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 1 阅读全文
posted @ 2019-11-17 06:24 xuan_abc 阅读(99) 评论(0) 推荐(0) 编辑
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: 阅读全文
posted @ 2019-11-17 05:06 xuan_abc 阅读(117) 评论(0) 推荐(0) 编辑
摘要:Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assum 阅读全文
posted @ 2019-11-17 00:54 xuan_abc 阅读(174) 评论(0) 推荐(0) 编辑
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1: Input: [3,0,1] Output 阅读全文
posted @ 2019-11-15 11:57 xuan_abc 阅读(76) 评论(0) 推荐(0) 编辑
摘要:Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight). Example 1: Input: 0000000 阅读全文
posted @ 2019-11-14 11:46 xuan_abc 阅读(108) 评论(0) 推荐(0) 编辑
摘要:Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: Input: 16 Out 阅读全文
posted @ 2019-11-14 11:04 xuan_abc 阅读(77) 评论(0) 推荐(0) 编辑
摘要:Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at 阅读全文
posted @ 2019-11-13 12:32 xuan_abc 阅读(99) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runti 阅读全文
posted @ 2019-11-13 12:21 xuan_abc 阅读(87) 评论(0) 推荐(0) 编辑
摘要:A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Write a function to determine if a number i 阅读全文
posted @ 2019-11-12 11:03 xuan_abc 阅读(85) 评论(0) 推荐(0) 编辑
摘要:Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is po 阅读全文
posted @ 2019-11-12 10:30 xuan_abc 阅读(135) 评论(0) 推荐(0) 编辑
摘要:Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "anagram", t = "nagaram" Output: true Example 阅读全文
posted @ 2019-11-12 08:47 xuan_abc 阅读(112) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 阅读全文
posted @ 2019-11-11 09:27 xuan_abc 阅读(114) 评论(0) 推荐(0) 编辑
摘要:Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Exampl 阅读全文
posted @ 2019-11-11 05:56 xuan_abc 阅读(104) 评论(0) 推荐(0) 编辑
摘要:Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0. You may assume 阅读全文
posted @ 2019-11-11 05:43 xuan_abc 阅读(129) 评论(0) 推荐(0) 编辑
摘要:Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystac 阅读全文
posted @ 2019-11-10 11:10 xuan_abc 阅读(109) 评论(0) 推荐(0) 编辑
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 阅读全文
posted @ 2019-11-10 10:17 xuan_abc 阅读(139) 评论(0) 推荐(0) 编辑
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist 阅读全文
posted @ 2019-11-10 05:07 xuan_abc 阅读(318) 评论(0) 推荐(0) 编辑
摘要:Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or 阅读全文
posted @ 2019-11-10 00:42 xuan_abc 阅读(120) 评论(0) 推荐(0) 编辑
摘要:Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is be 阅读全文
posted @ 2019-11-05 12:02 xuan_abc 阅读(165) 评论(0) 推荐(0) 编辑
摘要:Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path. In a UNIX-style file system, a perio 阅读全文
posted @ 2019-11-03 11:40 xuan_abc 阅读(91) 评论(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. to 阅读全文
posted @ 2019-11-02 11:02 xuan_abc 阅读(114) 评论(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 阅读全文
posted @ 2019-11-01 11:43 xuan_abc 阅读(109) 评论(0) 推荐(0) 编辑
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文
posted @ 2019-11-01 10:52 xuan_abc 阅读(157) 评论(0) 推荐(0) 编辑