随笔分类 - 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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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.
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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)
阅读全文
摘要:Given two 1d vectors, implement an iterator to return their elements alternately. For example, given two 1d vectors: By calling next repeatedly until
阅读全文
摘要: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
阅读全文
摘要: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.
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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.
阅读全文

浙公网安备 33010602011771号