随笔分类 -  Array

摘要:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or 阅读全文
posted @ 2016-08-02 10:27 北叶青藤 阅读(189) 评论(0) 推荐(0)
摘要:Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. For example, Assume that words 阅读全文
posted @ 2016-07-28 11:38 北叶青藤 阅读(217) 评论(0) 推荐(0)
摘要:Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the following rules: A move is guaranteed to be valid and 阅读全文
posted @ 2016-07-27 21:01 北叶青藤 阅读(179) 评论(0) 推荐(0)
摘要:Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Return 0 if the array contains less than 2 el 阅读全文
posted @ 2016-07-27 11:13 北叶青藤 阅读(194) 评论(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]. 分析: http://blog.csd 阅读全文
posted @ 2016-07-27 01:24 北叶青藤 阅读(213) 评论(0) 推荐(0)
摘要:Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloon 阅读全文
posted @ 2016-07-24 04:29 北叶青藤 阅读(233) 评论(0) 推荐(0)
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target va 阅读全文
posted @ 2016-07-22 10:59 北叶青藤 阅读(170) 评论(0) 推荐(0)
摘要:Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. Th 阅读全文
posted @ 2016-07-22 04:15 北叶青藤 阅读(238) 评论(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)
摘要:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two 阅读全文
posted @ 2016-07-21 02:46 北叶青藤 阅读(200) 评论(0) 推荐(0)
摘要:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. Example Given 4 points: (1,2), (3,6), (0,0), (1,3) 阅读全文
posted @ 2016-07-21 01:28 北叶青藤 阅读(261) 评论(0) 推荐(0)
摘要:Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping between nuts and bolts. Comparison of a nut to ano 阅读全文
posted @ 2016-07-20 22:42 北叶青藤 阅读(274) 评论(0) 推荐(0)
摘要:Given an array of n integer with duplicate number, and a moving window(size k), move the window at each iteration from the start of the array, find th 阅读全文
posted @ 2016-07-20 05:33 北叶青藤 阅读(160) 评论(0) 推荐(0)
摘要:Given an integer matrix, find a submatrix where the sum of numbers is zero. Your code should return the coordinate of the left-up and right-down numbe 阅读全文
posted @ 2016-07-20 04:04 北叶青藤 阅读(344) 评论(0) 推荐(0)
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area. Given a 2D binary matrix filled with 阅读全文
posted @ 2016-07-19 13:28 北叶青藤 阅读(180) 评论(0) 推荐(0)
摘要:Given a 2D boolean matrix filled with False and True, find the largest rectangle containing all True and return its area. Given a 2D boolean matrix fi 阅读全文
posted @ 2016-07-19 11:20 北叶青藤 阅读(163) 评论(0) 推荐(0)
摘要:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise). You are given an n x n 2D matrix representing an im 阅读全文
posted @ 2016-07-19 07:29 北叶青藤 阅读(199) 评论(0) 推荐(0)
摘要:Given a permutation which contains no repeated number, find its index in all the permutations of these numbers, which are ordered in lexicographical o 阅读全文
posted @ 2016-07-19 00:43 北叶青藤 阅读(332) 评论(0) 推荐(0)
摘要:Spiral Matrix I Given an integer n, generate a square matrix filled with elements from 1 to n^2 in spiral order. Example Given n = 3, You should retur 阅读全文
posted @ 2016-07-18 11:44 北叶青藤 阅读(208) 评论(0) 推荐(0)
摘要:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O''s into 'X''s in that surround 阅读全文
posted @ 2016-07-18 05:43 北叶青藤 阅读(215) 评论(0) 推荐(0)