随笔分类 -  leetcode

1 2 3 4 5 ··· 7 下一页

minimun depth of binary tree
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文

posted @ 2018-02-05 10:51 夜的第八章 阅读(154) 评论(0) 推荐(0)

Insert Interval
摘要:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文

posted @ 2018-01-23 13:00 夜的第八章 阅读(137) 评论(2) 推荐(0)

candy(贪心)
摘要:【题目】 There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the followi 阅读全文

posted @ 2018-01-23 10:50 夜的第八章 阅读(250) 评论(0) 推荐(0)

Best Time to Buy and Sell Stock
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文

posted @ 2018-01-22 18:21 夜的第八章 阅读(139) 评论(0) 推荐(0)

Best Time to Buy and Sell Stock III
摘要: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 阅读全文

posted @ 2018-01-22 18:15 夜的第八章 阅读(140) 评论(0) 推荐(0)

distinct subsequences
摘要:Given a string S and a string T, count the number of distinct subsequences of S which equals T. A subsequence of a string is a new string which is for 阅读全文

posted @ 2018-01-22 15:53 夜的第八章 阅读(122) 评论(0) 推荐(0)

edit distance(编辑距离,两个字符串之间相似性的问题)
摘要:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have 阅读全文

posted @ 2018-01-21 16:04 夜的第八章 阅读(165) 评论(0) 推荐(0)

trapping rain water
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. 阅读全文

posted @ 2018-01-21 11:45 夜的第八章 阅读(144) 评论(0) 推荐(0)

word break II(单词切分)
摘要:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is 阅读全文

posted @ 2018-01-20 16:54 夜的第八章 阅读(186) 评论(0) 推荐(0)

sudoku solver(数独)
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be 阅读全文

posted @ 2018-01-20 11:28 夜的第八章 阅读(192) 评论(0) 推荐(0)

N-Queens(N皇后问题)
摘要:题目: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return 阅读全文

posted @ 2018-01-19 21:17 夜的第八章 阅读(199) 评论(0) 推荐(0)

jump game II
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文

posted @ 2018-01-19 16:06 夜的第八章 阅读(156) 评论(0) 推荐(0)

sort list(给链表排序)
摘要:Sort a linked list in O(n log n) time using constant space complexity. 题目要求使用O(nlogn)时间复杂度,可以考虑使用归并排序,在 merge two sorted lists 中,已经知道了将两个有序链表进行合并。这里只要 阅读全文

posted @ 2018-01-18 10:59 夜的第八章 阅读(350) 评论(0) 推荐(0)

reorder list(链表重新排序)
摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For 阅读全文

posted @ 2018-01-17 16:32 夜的第八章 阅读(162) 评论(0) 推荐(0)

insertion sort list (使用插入排序给链表排序)
摘要:Sort a linked list using insertion sort. 对于数组的插入排序,可以参看排序算法入门之插入排序(java实现),遍历每个元素,然后相当于把每个元素插入到前面已经排好序的数组里,对于数组,只要当前元素比前一个元素小,则前一个元素后移,然后继续跟再前面的元素比。 对 阅读全文

posted @ 2018-01-17 12:57 夜的第八章 阅读(322) 评论(0) 推荐(0)

Copy List with Random Pointer(复杂链表复制)
摘要:输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head。(注意,输出结果中请不要返回参数中的节点引用,否则判题程序会直接返回空) 第一种方法:使用map存放原节点和其复制节点。然后再给复制节点的next/rando 阅读全文

posted @ 2018-01-17 10:40 夜的第八章 阅读(138) 评论(0) 推荐(0)

gas station
摘要:Gas Station There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank 阅读全文

posted @ 2018-01-15 18:51 夜的第八章 阅读(205) 评论(0) 推荐(0)

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 e 阅读全文

posted @ 2018-01-12 16:15 夜的第八章 阅读(210) 评论(0) 推荐(0)

Sum Root to Leaf Numbers
摘要:Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 whic 阅读全文

posted @ 2018-01-12 13:08 夜的第八章 阅读(97) 评论(0) 推荐(0)

Evaluate Reverse Polish Notation
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e 阅读全文

posted @ 2018-01-12 10:23 夜的第八章 阅读(110) 评论(0) 推荐(0)

1 2 3 4 5 ··· 7 下一页

导航