算法题
文章平均质量分 83
ygtrece
这个作者很懒,什么都没留下…
展开
-
LeetCode#33 Search in Rotated Sorted Array
题目Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to search. If found...原创 2020-03-02 21:16:24 · 169 阅读 · 0 评论 -
LeetCode#402 Remove K Digits
题目Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is less than 10002 and will be ≥ k...原创 2020-02-09 00:03:26 · 157 阅读 · 0 评论 -
LeetCode#99 Recover Binary Search Tree
题目Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Follow up:A solution using O(n) space is pretty straight forward.Could you de...原创 2020-02-08 23:55:41 · 193 阅读 · 0 评论 -
LeetCode#494 Target Sum (week14)
week14题目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 one from + and - as its new symbol.Find out ho原创 2017-12-07 11:13:39 · 125 阅读 · 0 评论 -
LeetCode#445 Add Two Numbers II (week15)
week15题目You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contain a single digit. Add the two numbers and r原创 2017-12-17 01:07:53 · 151 阅读 · 0 评论 -
Exercises 8.16 (week17)
week17题目We are feeling experimental and want to create a new dish. There are various ingredients we can choose from and we’d like to use as many of them as possible, but some ingredients don’t go well原创 2018-01-02 15:04:46 · 236 阅读 · 0 评论 -
LeetCode#689 Maximum Sum of 3 Non-Overlapping Subarrays(week18)
week18题目In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum.Each subarray will be of size k, and we want to maximize the sum of all 3*k entries.原创 2018-01-07 23:50:08 · 431 阅读 · 0 评论 -
LeetCode#698 Partition to K Equal Sum Subsets(week19)
week19题目Given an array of integers nums and a positive integer k, find whether it’s possible to divide this array into k non-empty subsets whose sums are all equal. Note:1 <= k <= len(nums) <= 16.原创 2018-01-13 14:49:51 · 199 阅读 · 0 评论 -
LeetCode#743 Network Delay Time(week19)
week19题目There are N network nodes, labelled 1 to N.Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the target node, and w is the time it tak原创 2018-01-13 19:07:12 · 259 阅读 · 0 评论 -
LeetCode#554 Brick Wall (week14)
week14题目There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. You want to draw a vertical line from the top原创 2017-12-06 21:06:04 · 204 阅读 · 0 评论 -
LeetCode#648 Replace Words (week14)
week14题目In English, we have a concept called root, which can be followed by some other words to form another longer word - let’s call this word successor. For example, the root an, followed by other, w原创 2017-12-06 11:54:01 · 164 阅读 · 0 评论 -
LeetCode#746 Min Cost Climbing Stairs (week16)
week16题目On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the to原创 2017-12-22 21:28:08 · 354 阅读 · 0 评论 -
LeetCode#718 Maximum Length of Repeated Subarray (week9)
week9题目Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1: Input: A: [1,2,3,2,1] B: [3,2,1,4,7] Output: 3 Explanation: The repeated原创 2017-10-31 18:19:16 · 348 阅读 · 0 评论 -
LeetCode#712 Minimum ASCII Delete Sum for Two Strings (week10)
week10题目Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1: Input: s1 = “sea”, s2 = “eat” Output: 231 Explanation: Deleting “s” from “sea”原创 2017-11-10 18:59:28 · 130 阅读 · 0 评论 -
LeetCode#238 Product of Array Except Self (week11)
week11题目Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(原创 2017-11-18 18:44:10 · 159 阅读 · 0 评论 -
LeetCode#654 Maximum Binary Tree (week12)
week12题目Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array. The left subtree is the maximum tree construc原创 2017-11-22 19:58:22 · 169 阅读 · 0 评论 -
Sicily 拓扑排序
题目在图论中,拓扑序(Topological Sorting)是一个有向无环图(DAG, Directed Acyclic Graph)的所有顶点的线性序列. 且该序列必须满足下面两个条件:每个顶点出现且只出现一次.若存在一条从顶点 A 到顶点 B 的路径,那么在序列中顶点 A 出现在顶点 B 的前面.对于一个含有n个节点的有向无环图(节点编号0到n-1),输出它的一个拓扑序.图的节点数和边数原创 2017-11-23 00:56:31 · 364 阅读 · 0 评论 -
LeetCode#515 Find Largest Value in Each Tree Row (week15)
week15题目You need to find the largest value in each row of a binary tree. 原题地址:https://leetcode.com/problems/find-largest-value-in-each-tree-row/description/解析题目要求给定一棵二叉树,找出每一层的最大的节点的值。 大致思路是先对树进行一次原创 2017-12-11 20:32:05 · 159 阅读 · 0 评论 -
LeetCode#671 Second Minimum Node In a Binary Tree (week13)
week13题目Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the node has two sub-nodes, then this no原创 2017-12-05 00:37:17 · 215 阅读 · 0 评论 -
LeetCode#740 Delete and Earn (week16)
week16题目Given an array nums of integers, you can perform operations on the array.In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal原创 2017-12-23 00:50:52 · 205 阅读 · 0 评论 -
LeetCode#264 Ugly Number II (week8)
week8题目Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first原创 2017-10-28 01:56:05 · 128 阅读 · 0 评论