关闭

[leetcode] 329. Longest Increasing Path in a Matrix

题目: Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside...
阅读(286) 评论(0)

[leetcode] 334. Increasing Triplet Subsequence

题目: 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 there exists i, j, k such that arr[i] < arr[...
阅读(299) 评论(0)

[leetcode] 310. Minimum Height Trees

题目: For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called...
阅读(402) 评论(0)

[leetcode] 309. Best Time to Buy and Sell Stock with Cooldown

题目: 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 complete as many transactions as you like (ie, buy on...
阅读(1056) 评论(2)

[leetcode] 306. Additive Number

题目: Additive number is a string whose digits can form additive sequence.A valid additive sequence should contain at least three numbers. Except for the first two numbers, each subsequent number in the...
阅读(639) 评论(0)

[leetcode] 299. Bulls and Cows

题目: 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 your friend makes a guess, you provide a hint...
阅读(248) 评论(0)

[leetcode] 304. Range Sum Query 2D - Immutable

题目: 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, col2).Range Sum Query 2D The above rectangl...
阅读(186) 评论(0)

[leetcode] 301. Remove Invalid Parentheses

题目: Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may contain letters other than the parentheses ( and )....
阅读(864) 评论(0)

[leetcode] 300. Longest Increasing Subsequence

题目: 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 increasing subsequence is [2, 3, 7, 101], ther...
阅读(257) 评论(0)

[leetcode] 295. Find Median from Data Stream

题目:Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4] , the median i...
阅读(310) 评论(0)

[leetcode] 292.Nim Game

题目: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be...
阅读(759) 评论(0)

[leetcode] 287.Find the Duplicate Number

题目: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate element must exist. Assume that there is only one duplicate numbe...
阅读(978) 评论(1)

[leetcode] 275.H-Index II

题目: Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm? 题意: 这道题目是接274题而来,不过这次的引用次数是按照升序排列的。 思路: 可以使用二分查找的方法进行,扫描到middle元素的时候,如果middl...
阅读(515) 评论(0)

[leetcode] 274.H-Index

题目: 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 to the definition of h-index on Wikipedia: “A...
阅读(1013) 评论(0)

[leetcode] 174.Dungeon Game

题目: The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially...
阅读(275) 评论(0)

[leetcode] 140.Word Break II

题目: Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, given s = “cats...
阅读(236) 评论(0)

[leetcode] 139.Word Break

题目: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, given s = “leetcode”, dict = [“leet”...
阅读(231) 评论(0)

[leetcode] 67.Add Binary

题目: Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”. 题意: 给定两个二进制的字符串,返回它们的和。 思路: 这道题目就是完成简单的二进制的加法。代码如下:class Solution { public:...
阅读(204) 评论(0)

[leetcode] 49.Group Anagrams

题目: Given an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return:[ [“ate”, “eat”,”tea”], [“nat”,”tan”], [“bat”] ] Note: For t...
阅读(229) 评论(0)

[leetcode] 115.Distinct Subsequences

题目: Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non...
阅读(218) 评论(0)
239条 共12页1 2 3 4 5 ... 下一页 尾页
    个人资料
    • 访问:60997次
    • 积分:2882
    • 等级:
    • 排名:第13658名
    • 原创:239篇
    • 转载:0篇
    • 译文:0篇
    • 评论:5条
    文章分类
    最新评论