原文链接: https://leetcode-cn.com/problems/best-line-lcci 英文原文Given a two-dimensional graph with points on it, find a line which passes the most number of points. Assume all the points that passed by the line are stored in list S sorted by their number. …
分类详情
中等 分类
原文链接: https://leetcode-cn.com/problems/sub-sort-lcci 英文原文Given an array of integers, write a method to find indices m and n such that if you sorted elements m through n, the entire array would be sorted. Minimize n - m (that is, find the smallest suc…
原文链接: https://leetcode-cn.com/problems/pond-sizes-lcci 英文原文You have an integer matrix representing a plot of land, where the value at that loca­tion represents the height above sea level. A value of zero indicates water. A pond is a region of wat…
原文链接: https://leetcode-cn.com/problems/one-away-lcci 英文原文There are three types of edits that can be performed on strings: insert a character, remove a character, or replace a character. Given two strings, write a function to check if they are one edi…
原文链接: https://leetcode-cn.com/problems/partition-list-lcci 英文原文Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x. If x is contained within the list, the values of …
原文链接: https://leetcode-cn.com/problems/paths-with-sum-lcci 英文原文You are given a binary tree in which each node contains an integer value (which might be positive or negative). Design an algorithm to count the number of paths that sum to a given value.…
原文链接: https://leetcode-cn.com/problems/robot-in-a-grid-lcci 英文原文Imagine a robot sitting on the upper left corner of grid with r rows and c columns. The robot can only move in two directions, right and down, but certain cells are "off limits" such tha…
原文链接: https://leetcode-cn.com/problems/peaks-and-valleys-lcci 英文原文In an array of integers, a "peak" is an element which is greater than or equal to the adjacent integers and a "valley" is an element which is less than or equal to the adjacent inte&sh…
原文链接: https://leetcode-cn.com/problems/pattern-matching-lcci 英文原文You are given two strings, pattern and value. The pattern string consists of just the letters a and b, describing a pattern within a string. For example, the string catcatgocatgo matche…
原文链接: https://leetcode-cn.com/problems/sorted-matrix-search-lcci 英文原文Given an M x N matrix in which each row and each column is sorted in ascending order, write a method to find an element. Example: Given matrix: [ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19…
原文链接: https://leetcode-cn.com/problems/re-space-lcci 英文原文Oh, no! You have accidentally removed all spaces, punctuation, and capitalization in a lengthy document. A sentence like "I reset the computer. It still didn't boot!" became "iresetthecomputeri…
原文链接: https://leetcode-cn.com/problems/longest-word-lcci 英文原文Given a list of words, write a program to find the longest word made of other words in the list. If there are more than one answer, return the one that has smallest lexicographic order. If …
原文链接: https://leetcode-cn.com/problems/smallest-k-lcci 英文原文Design an algorithm to find the smallest K numbers in an array. Example: Input: arr = [1,3,5,7,2,4,6,8], k = 4 Output: [1,2,3,4] Note: 0 <= len(arr) <= 100000 0 <= k <= min(100000, len(arr)) …
原文链接: https://leetcode-cn.com/problems/multi-search-lcci 英文原文Given a string band an array of smaller strings T, design a method to search b for each small string in T. Output positions of all strings in smalls that appear in big, where positions[i] i…
原文链接: https://leetcode-cn.com/problems/lru-cache-lcci 英文原文Design and build a "least recently used" cache, which evicts the least recently used item. The cache should map from keys to values (allowing you to insert and retrieve a value associ­ated…
原文链接: https://leetcode-cn.com/problems/calculator-lcci 英文原文Given an arithmetic equation consisting of positive integers, +, -, * and / (no paren­theses), compute the result. The expression string contains only non-negative integers, +, -, *, / op…
原文链接: https://leetcode-cn.com/problems/word-transformer-lcci 英文原文Given two words of equal length that are in a dictionary, write a method to transform one word into another word by changing only one letter at a time. The new word you get in each step…
原文链接: https://leetcode-cn.com/problems/boolean-evaluation-lcci 英文原文Given a boolean expression consisting of the symbols 0 (false), 1 (true), & (AND), | (OR), and ^ (XOR), and a desired boolean result value result, implement a function to count the nu…
原文链接: https://leetcode-cn.com/problems/find-longest-subarray-lcci 英文原文Given an array filled with letters and numbers, find the longest subarray with an equal number of letters and numbers. Return the subarray. If there are more than one answer, retur…
原文链接: https://leetcode-cn.com/problems/baby-names-lcci 英文原文Each year, the government releases a list of the 10000 most common baby names and their frequencies (the number of babies with that name). The only problem with this is that some names have m…
原文链接: https://leetcode-cn.com/problems/circus-tower-lcci 英文原文A circus is designing a tower routine consisting of people standing atop one anoth­er's shoulders. For practical and aesthetic reasons, each person must be both shorter and lighter than…
原文链接: https://leetcode-cn.com/problems/get-kth-magic-number-lcci 英文原文Design an algorithm to find the kth number such that the only prime factors are 3, 5, and 7. Note that 3, 5, and 7 do not have to be factors, but it should not have any other prime …
原文链接: https://leetcode-cn.com/problems/find-closest-lcci 英文原文You have a large text file containing words. Given any two words, find the shortest distance (in terms of number of words) between them in the file. If the operation will be repeated many t…
原文链接: https://leetcode-cn.com/problems/rank-from-stream-lcci 英文原文Imagine you are reading in a stream of integers. Periodically, you wish to be able to look up the rank of a number x (the number of values less than or equal to x). lmplement the data s…
原文链接: https://leetcode-cn.com/problems/pairs-with-sum-lcci 英文原文Design an algorithm to find all pairs of integers within an array which sum to a specified value. Example 1: Input: nums = [5,6,5], target = 11 Output: [[5,6]] Example 2: Input: nums = [5…
原文链接: https://leetcode-cn.com/problems/shortest-supersequence-lcci 英文原文You are given two arrays, one shorter (with all distinct elements) and one longer. Find the shortest subarray in the longer array that contains all the elements in the shorter arr…
原文链接: https://leetcode-cn.com/problems/max-black-square-lcci 英文原文Imagine you have a square matrix, where each cell (pixel) is either black or white Design an algorithm to find the maximum subsquare such that all four borders are filled with black pix…
原文链接: https://leetcode-cn.com/problems/t9-lcci 英文原文On old cell phones, users typed on a numeric keypad and the phone would provide a list of words that matched these numbers. Each digit mapped to a set of 0 - 4 letters. Implement an algo­rithm to…
原文链接: https://leetcode-cn.com/problems/sum-swap-lcci 英文原文Given two arrays of integers, find a pair of values (one value from each array) that you can swap to give the two arrays the same sum. Return an array, where the first element is the element in…
原文链接: https://leetcode-cn.com/problems/langtons-ant-lcci 英文原文An ant is sitting on an infinite grid of white and black squares. It initially faces right. All squares are white initially. At each step, it does the following: (1) At a white square, flip…