随笔分类 -  Array

摘要:Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algor 阅读全文
posted @ 2016-11-17 14:17 北叶青藤 阅读(282) 评论(0) 推荐(0)
摘要:A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but i 阅读全文
posted @ 2016-11-04 22:09 北叶青藤 阅读(452) 评论(0) 推荐(0)
摘要:Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array. Formally the function should: Return true if 阅读全文
posted @ 2016-10-17 10:58 北叶青藤 阅读(125) 评论(0) 推荐(0)
摘要:Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tick 阅读全文
posted @ 2016-10-17 09:40 北叶青藤 阅读(269) 评论(0) 推荐(0)
摘要:Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n]inclusive can be form 阅读全文
posted @ 2016-10-16 12:03 北叶青藤 阅读(244) 评论(0) 推荐(0)
摘要:An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one bla 阅读全文
posted @ 2016-10-15 11:49 北叶青藤 阅读(210) 评论(0) 推荐(0)
摘要:There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have t 阅读全文
posted @ 2016-10-11 11:48 北叶青藤 阅读(388) 评论(0) 推荐(0)
摘要:Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. 阅读全文
posted @ 2016-10-11 11:09 北叶青藤 阅读(323) 评论(0) 推荐(0)
摘要:You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an obstacle. 0 - A gate. INF - Infinity means an empty room 阅读全文
posted @ 2016-10-10 07:37 北叶青藤 阅读(194) 评论(0) 推荐(0)
摘要:Contains Duplicate I Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at l 阅读全文
posted @ 2016-10-10 06:04 北叶青藤 阅读(256) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2016-08-09 03:59 北叶青藤 阅读(293) 评论(0) 推荐(0)
摘要:Union-Find Algrithm is used to check whether two components are connected or not. Examples: By using the graph, we can easily find whether two compone 阅读全文
posted @ 2016-08-09 02:25 北叶青藤 阅读(632) 评论(0) 推荐(0)
摘要:According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John 阅读全文
posted @ 2016-08-08 22:13 北叶青藤 阅读(402) 评论(0) 推荐(0)
摘要:Range Sum Query 2D - Mutable Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) 阅读全文
posted @ 2016-08-06 23:13 北叶青藤 阅读(222) 评论(0) 推荐(0)
摘要:Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: By calling next repeatedly until 阅读全文
posted @ 2016-08-06 06:14 北叶青藤 阅读(251) 评论(0) 推荐(0)
摘要:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font 阅读全文
posted @ 2016-08-05 11:49 北叶青藤 阅读(239) 评论(0) 推荐(0)
摘要:H-Index I Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. 阅读全文
posted @ 2016-08-05 11:06 北叶青藤 阅读(198) 评论(0) 推荐(0)
摘要:A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the h 阅读全文
posted @ 2016-08-05 00:34 北叶青藤 阅读(262) 评论(0) 推荐(0)
摘要:Given two sparse matrices A and B, return the result of AB. You may assume that A's column number is equal to B's row number. Example: A = [ [ 1, 0, 0 阅读全文
posted @ 2016-08-04 05:39 北叶青藤 阅读(174) 评论(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)