随笔分类 -  算法题

摘要:Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2 阅读全文
posted @ 2019-05-18 20:38 小白兔云 阅读(122) 评论(0) 推荐(0)
摘要:Additive number is a string whose digits can form additive sequence. A valid additive sequence should contain at least three numbers. Except for the f 阅读全文
posted @ 2019-05-18 17:41 小白兔云 阅读(187) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Note: There may be more than one LIS combination, it 阅读全文
posted @ 2019-05-14 21:06 小白兔云 阅读(106) 评论(0) 推荐(0)
摘要:You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time 阅读全文
posted @ 2019-05-14 20:34 小白兔云 阅读(128) 评论(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 @ 2019-05-14 17:37 小白兔云 阅读(171) 评论(0) 推荐(0)
摘要:Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it e 阅读全文
posted @ 2019-05-13 15:26 小白兔云 阅读(116) 评论(0) 推荐(0)
摘要:Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a researcher, write a function to compute the resea 阅读全文
posted @ 2019-05-13 10:06 小白兔云 阅读(130) 评论(0) 推荐(0)
摘要: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. According 阅读全文
posted @ 2019-05-13 09:38 小白兔云 阅读(162) 评论(0) 推荐(0)
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Example 2: 题目大意 阅读全文
posted @ 2019-05-12 23:16 小白兔云 阅读(135) 评论(0) 推荐(0)
摘要:Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example: Input: n = 10 Outpu 阅读全文
posted @ 2019-05-10 09:22 小白兔云 阅读(137) 评论(0) 推荐(0)
摘要:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements 阅读全文
posted @ 2019-05-09 21:35 小白兔云 阅读(156) 评论(0) 推荐(0)
摘要:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. Th 阅读全文
posted @ 2019-05-09 21:14 小白兔云 阅读(110) 评论(0) 推荐(0)
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted i 阅读全文
posted @ 2019-05-08 18:44 小白兔云 阅读(116) 评论(0) 推荐(0)
摘要:Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except n 阅读全文
posted @ 2019-05-08 18:26 小白兔云 阅读(105) 评论(0) 推荐(0)
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
posted @ 2019-05-08 18:03 小白兔云 阅读(104) 评论(0) 推荐(0)
摘要:Given a sorted integer array without duplicates, return the summary of its ranges. Example 1: Input: [0,1,2,4,5,7] Output: ["0->2","4->5","7"] Explana 阅读全文
posted @ 2019-05-06 10:38 小白兔云 阅读(121) 评论(0) 推荐(0)
摘要:Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's 阅读全文
posted @ 2019-05-06 10:35 小白兔云 阅读(159) 评论(0) 推荐(0)
摘要:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋times. Note: The algorithm should run in linear time and in O(1) spac 阅读全文
posted @ 2019-05-06 10:31 小白兔云 阅读(169) 评论(0) 推荐(0)
摘要:Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as s 阅读全文
posted @ 2019-05-05 15:23 小白兔云 阅读(213) 评论(0) 推荐(0)
摘要:Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators a 阅读全文
posted @ 2019-05-05 14:57 小白兔云 阅读(163) 评论(0) 推荐(0)