随笔分类 -  Leetcode

leetcode practice notes
摘要:Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and t 阅读全文
posted @ 2017-06-29 14:25 安新 阅读(353) 评论(0) 推荐(0)
摘要:Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs. We define an in 阅读全文
posted @ 2017-06-26 14:03 安新 阅读(322) 评论(0) 推荐(0)
摘要:You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose o 阅读全文
posted @ 2017-06-25 23:02 安新 阅读(263) 评论(0) 推荐(0)
摘要:We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2017-06-24 13:12 安新 阅读(250) 评论(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 @ 2017-06-21 06:49 安新 阅读(443) 评论(0) 推荐(0)
摘要:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam 阅读全文
posted @ 2017-06-19 13:31 安新 阅读(319) 评论(0) 推荐(0)
摘要:Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, ex 阅读全文
posted @ 2017-06-19 00:03 安新 阅读(220) 评论(0) 推荐(0)
摘要:Given a string s and a string t, check if s is subsequence of t. Given a string s and a string t, check if s is subsequence of t. You may assume that 阅读全文
posted @ 2017-06-13 04:59 安新 阅读(370) 评论(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 @ 2017-06-11 23:24 安新 阅读(216) 评论(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 @ 2017-06-10 23:56 安新 阅读(214) 评论(0) 推荐(0)
摘要:Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm? Solution: # this is could also be 阅读全文
posted @ 2017-06-10 10:44 安新 阅读(172) 评论(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 @ 2017-06-10 09:02 安新 阅读(179) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of longest increasing subsequence. For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest inc 阅读全文
posted @ 2017-06-08 12:16 安新 阅读(282) 评论(0) 推荐(0)
摘要:Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point o 阅读全文
posted @ 2017-06-05 06:49 安新 阅读(221) 评论(0) 推荐(0)
摘要:Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses. Now, you are given p 阅读全文
posted @ 2017-06-04 12:57 安新 阅读(357) 评论(0) 推荐(0)