08 2017 档案
摘要: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
阅读全文
摘要:Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and the
阅读全文
摘要:Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by upd
阅读全文
摘要:Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the ave
阅读全文
摘要:Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element
阅读全文
摘要:Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the or
阅读全文
摘要:Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subt
阅读全文
摘要:For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now i
阅读全文
摘要:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function
阅读全文
摘要:Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. E
阅读全文
摘要:Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of
阅读全文
摘要:Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: Construct the maximum tree by the given array a
阅读全文
摘要:Given two strings representing two complex numbers. You need to return a string representing their multiplication. Note i2 = -1 according to the defin
阅读全文
摘要:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twi
阅读全文
摘要:Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Example 2:
阅读全文
摘要:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and r
阅读全文
摘要: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
阅读全文
摘要:Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a
阅读全文
摘要:Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longestpath betwee
阅读全文
摘要: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]
阅读全文
摘要:You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/ve
阅读全文
摘要:You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way. The null node needs to be rep
阅读全文
摘要:Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defi
阅读全文
摘要: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 Outp
阅读全文
摘要:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.
阅读全文
摘要:Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of th
阅读全文