
算法
Valerie7012
渣渣
展开
-
算法期中——拓扑序[Special judge]
拓扑序[Special judge]在图论中,拓扑序(Topological Sorting)是一个有向无环图(DAG, Directed Acyclic Graph)的所有顶点的线性序列.原创 2017-12-07 09:36:34 · 478 阅读 · 0 评论 -
Excel Sheet Column Number(leetcode)
Excel Sheet Column NumberGiven a column title as appear in an Excel sheet, return its corresponding column number.原创 2017-12-19 15:26:49 · 246 阅读 · 0 评论 -
Minimum Moves to Equal Array Elements(leetcode)
Minimum Moves to Equal Array ElementsGiven a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.原创 2017-12-19 15:42:04 · 216 阅读 · 0 评论 -
Best Time to Buy and Sell Stock II(leetcode)
Best Time to Buy and Sell Stock IIDesign an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times).原创 2017-12-19 15:48:28 · 233 阅读 · 0 评论 -
Find Smallest Letter Greater Than Target(leetcode)
Find Smallest Letter Greater Than TargetGiven a list of sorted characters letters and given a target letter target, find the smallest element in the list that is larger than the given target.原创 2017-12-19 16:14:09 · 361 阅读 · 0 评论 -
Course Schedule(leetcode)
Course ScheduleThere are a total of n courses you have to take, labeled from 0 to n - 1.Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses?原创 2017-12-19 16:17:16 · 294 阅读 · 0 评论 -
771.Jewels and Stones (leetcode)
Strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones are also jewels.原创 2018-01-28 20:45:08 · 2452 阅读 · 0 评论 -
760. Find Anagram Mappings (leetcode)
Find Anagram MappingsGiven two lists A and B, and B is an anagram of A. We want We want to We want to find an index mapping P, from A to B. A mapping P[i] = j means the ith element in A appears in B at index j原创 2018-01-28 21:10:35 · 420 阅读 · 0 评论 -
766. Toeplitz Matrix (leetcode)
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given an M x N matrix, return True if and only if the matrix is Toeplitz.原创 2018-01-28 21:30:38 · 482 阅读 · 0 评论 -
804. Unique Morse Code Words
804. Unique Morse Code Words804. Unique Morse Code Words题目解决题目Leetcode题目International Morse Code defines a standard encoding where each letter is mapped to a series of dots and das...原创 2018-04-07 20:21:52 · 219 阅读 · 0 评论 -
Range Addition II(leetcode)
Range Addition IIGiven an m * n matrix M initialized with all 0's and several update operations. You need to count and return the number of maximum integers in the matrix after performing all the operations.原创 2017-12-19 15:21:50 · 265 阅读 · 0 评论 -
Construct the Rectangle(leetcode)
Construct the RectangleFor a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page.原创 2017-12-19 15:14:49 · 236 阅读 · 0 评论 -
Convert BST to Greater Tree(leetcode)
Convert BST to Greater TreeGiven a BST, convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.原创 2017-12-19 15:06:21 · 250 阅读 · 0 评论 -
算法期中——最小和
最小和从数列A[0], A[1], A[2], ..., A[N-1]中选若干个数,要求对于每个i(0<=i<N-1),A[i]和A[i+1]至少选一个数,求能选出的最小和.原创 2017-12-07 10:01:28 · 632 阅读 · 0 评论 -
算法期中——最长公共子串
最长公共子串给定两个字符串x = x1x2…xn和y = y1y2…ym, 请找出x和y的最长公共子串的长度,也就是求出一个最大的k,使得存在下标i和j有xixi+1…xi+k-1 = yjyj+1…yj+k-1.原创 2017-12-07 10:18:39 · 202 阅读 · 0 评论 -
Sum of Two Integers(leetcode)
Sum of Two IntegersCalculate the sum of two integers a and b, but you are not allowed to use the operator + and -.原创 2017-12-07 10:26:17 · 233 阅读 · 0 评论 -
Find the Difference(leetcode)
Find the DifferenceGiven two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.原创 2017-12-07 10:34:04 · 258 阅读 · 0 评论 -
Move Zeroes(leetcode)
Move ZeroesGiven an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.原创 2017-12-07 10:46:20 · 179 阅读 · 0 评论 -
Two Sum IV - Input is a BST(leetcode)
Two Sum IV - Input is a BSTGiven a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.原创 2017-12-07 11:04:32 · 268 阅读 · 0 评论 -
Construct String from Binary Tree(leetcode)
Construct String from Binary TreeYou need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.原创 2017-12-07 11:07:27 · 229 阅读 · 0 评论 -
算法分析与设计——NP习题
算法概论 8.3题目STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k, find a satisfying assignment in which at most k variables are true, if原创 2018-01-11 13:00:44 · 418 阅读 · 0 评论 -
Flood Fill(leetcode)
Flood FillAn image is represented by a 2-D array of integers.Given a coordinate (sr, sc) representing the starting pixel (row and column) of the flood fill, and a pixel value newColor, "flood fill" the image.原创 2017-12-19 14:54:59 · 742 阅读 · 0 评论 -
762. Prime Number of Set Bits in Binary Representation
762. Prime Number of Set Bits in Binary Representation762. Prime Number of Set Bits in Binary Representation题目解决题目Leetcode题目Given two integers L and R, find the count of numbers in...原创 2018-04-21 15:34:08 · 236 阅读 · 0 评论 -
784. Letter Case Permutation
784. Letter Case Permutation784. Letter Case Permutation题目解决题目Leetcode题目Given a string S, we can transform every letter individually to be lowercase or uppercase to create another ...原创 2018-04-21 15:45:36 · 272 阅读 · 0 评论 -
893. Groups of Special-Equivalent Strings
You are given an array A of strings. Two strings S and T are special-equivalent if after any number of moves, S == T. A move consists of choosing two indices i and j with i % 2 == j % 2. Return the number of groups of special-equivalent strings.原创 2018-09-02 14:51:18 · 274 阅读 · 0 评论 -
892. Surface Area of 3D Shapes
On a N * N grid, we place some 1 * 1 * 1 cubes. Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j). Return the total surface area of the resulting shapes.原创 2018-09-02 15:55:59 · 332 阅读 · 0 评论 -
830. Positions of Large Groups
In a string S of lowercase letters, these letters form consecutive groups of the same character. Call a group large if it has 3 or more characters. We would like the starting and ending positions of every large group.原创 2018-09-02 16:05:13 · 255 阅读 · 0 评论 -
783. Minimum Distance Between BST Nodes
Given a Binary Search Tree (BST) with the root node root, return the minimum difference between the values of any two different nodes in the tree.原创 2018-09-02 16:10:32 · 200 阅读 · 0 评论 -
819. Most Common Word
Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn't banned, and that the answer is unique.原创 2018-09-02 16:18:46 · 301 阅读 · 0 评论 -
888. Fair Candy Swap
Return an integer array ans where ans[0] is the size of the candy bar that Alice must exchange, and ans[1] is the size of the candy bar that Bob must exchange.原创 2018-09-02 16:29:38 · 279 阅读 · 0 评论 -
844. Backspace String Compare
Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.原创 2018-09-03 20:36:41 · 279 阅读 · 0 评论 -
860. Lemonade Change
At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills).Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must pro原创 2018-09-03 20:44:49 · 239 阅读 · 0 评论 -
788. Rotated Digits
788. Rotated Digits788. Rotated Digits题目解决题目Leetcode题目X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X....原创 2018-09-03 20:49:26 · 302 阅读 · 0 评论 -
896. Monotonic Array
An array is monotonic if it is either monotone increasing or monotone decreasing. Return true if and only if the given array A is monotonic.原创 2018-09-02 14:25:19 · 488 阅读 · 0 评论 -
590. N-ary Tree Postorder Traversal
Given an n-ary tree, return the postorder traversal of its nodes' values.原创 2018-08-15 22:12:42 · 340 阅读 · 0 评论 -
559. Maximum Depth of N-ary Tree
Given a n-ary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.原创 2018-08-15 21:48:36 · 239 阅读 · 0 评论 -
806. Number of Lines To Write String
806. Number of Lines To Write String806. Number of Lines To Write String题目解决题目Leetcode题目We are to write the letters of a given string S, from left to right into lines. Each line ha...原创 2018-04-21 15:58:47 · 339 阅读 · 0 评论 -
811. Subdomain Visit Count
811. Subdomain Visit Count811. Subdomain Visit Count题目解决题目Leetcode题目A website domain like “discuss.leetcode.com” consists of various subdomains. At the top level, we have “com”, at...原创 2018-04-21 16:19:53 · 261 阅读 · 0 评论 -
812. Largest Triangle Area
812. Largest Triangle Area812. Largest Triangle Area题目解决题目Leetcode题目You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of...原创 2018-04-21 17:22:53 · 353 阅读 · 0 评论 -
709. To Lower Case
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.原创 2018-08-07 17:31:26 · 190 阅读 · 0 评论