
Lintcode
文章平均质量分 62
Lintcode题解
__KevinYzy__
github:https://github.com/KEVINYZY ----
leetcode:https://leetcode.com/seanadfgfeer/ ----
lintcode:https://www.lintcode.com/user/fire-blade ----
nowcoder:https://www.nowcoder.com/profile/1073818
展开
-
Lintcode 738.Count Different Palindromic Subsequences go
/**738 · 计数回文子序列算法HardAccepted Rate34%DescriptionSolutionNotesDiscussLeaderboardDescription给出一个字符串 S, 计算字符串 S 中不同非空回文子序列的数量, 返回这个数对 10^9 + 7 取模后得结果.字符串 S 的子序列可以通过删去 S 中 0 个或多个字符得到. 一个序列如果是回文的, 那么它逆序后与原序列相等.两个序列 A[1], A[2], … B[1], B[2], … 如果存在 A[原创 2021-06-16 11:37:29 · 277 阅读 · 0 评论 -
Lintcode 727 · Chinese Remainder Theorem go
/**727 · Chinese Remainder TheoremAlgorithmsHardAccepted Rate32%DescriptionSolutionNotesDiscussLeaderboardDescriptionWe are given two arrays num[0…k-1] and rem[0…k-1]. In num[0…k-1], every pair is coprime (gcd for every pair is 1). We need to find原创 2021-06-16 10:55:33 · 262 阅读 · 0 评论 -
Lintcode 721 · 下一个稀疏数 go
/**721 · 下一个稀疏数算法HardAccepted Rate38%DescriptionSolutionNotesDiscussLeaderboardDescription一个数是稀疏数如果这个数的 二进制表示 中没有相邻的 1,给出一个 n ,找出大于或等于 n 的最小的稀疏数。eg. 5 (二进制表示为 101)是稀疏数,但是 6 (二进制表示为 110 )不是稀疏数Example样例 1:输入:6输出:8解释:6 = 110(2) 并且 8 = 1000(2)样原创 2021-06-16 10:30:17 · 286 阅读 · 0 评论 -
Lintcode 699 · Check Sum of K Primes go
/**699 · Check Sum of K PrimesAlgorithmsHardAccepted Rate27%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven two numbers n and k. We need to find out if n can be written as sum of k prime numbers.n <= 10 ^ 9ExampleExample 1Input:n原创 2021-06-16 09:41:46 · 147 阅读 · 0 评论 -
Lintcode 676 · Decode Ways II go
/**676 · Decode Ways IIAlgorithmsHardAccepted Rate39%DescriptionSolutionNotesDiscussLeaderboardDescriptionA message containing letters from A-Z is being encoded to numbers using the following mapping way:‘A’ -> 1‘B’ -> 2…‘Z’ -> 26Beyo原创 2021-06-04 17:21:13 · 117 阅读 · 0 评论 -
Lintcode 639 · Word Abbreviation go
/**639 · 单词缩写算法HardAccepted Rate44%DescriptionSolutionNotesDiscussLeaderboardDescription给出一组 n 个不同的非空字符串,您需要按以下规则为每个单词生成 最小 的缩写。从第一个字符开始,然后加上中间缩写掉的字符的长度,后跟最后一个字符。如果有冲突,就是多个单词共享相同的缩写,使用较长的前缀,而不是仅使用第一个字符,直到使单词的缩写的映射变为唯一。 换句话说,最终得到的缩写不能映射到多个原始单词。如果原创 2021-06-03 19:10:39 · 124 阅读 · 0 评论 -
Lintcode 633 · Find the Duplicate Number go
/**633 · Find the Duplicate NumberAlgorithmsHardAccepted Rate49%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), guarantee that at least one duplic原创 2021-06-02 15:12:42 · 98 阅读 · 0 评论 -
Lintcode600 · Smallest Rectangle Enclosing Black Pixels go
/**600 · Smallest Rectangle Enclosing Black PixelsAlgorithmsHardAccepted Rate38%DescriptionSolutionNotesDiscussLeaderboardDescriptionAn image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are con原创 2021-06-01 19:27:16 · 209 阅读 · 0 评论 -
Lintcode516 · Paint House II go
/**516 · Paint House IIAlgorithmsHardAccepted Rate36%DescriptionSolutionNotesDiscussLeaderboardDescriptionThere are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is diffe原创 2021-05-31 19:18:21 · 118 阅读 · 0 评论 -
Lintcode 450 · Reverse Nodes in k-Group go
/**450 · Reverse Nodes in k-GroupAlgorithmsHardAccepted Rate40%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a mu原创 2021-05-19 14:29:21 · 96 阅读 · 0 评论 -
Lintcode430 · Scramble String go
/**430 · Scramble StringAlgorithmsHardAccepted Rate42%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible rep原创 2021-05-12 11:31:38 · 155 阅读 · 0 评论 -
Lintcode183 · Wood Cut go
/**183 · Wood CutAlgorithmsHardAccepted Rate29%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven n pieces of wood with length L[i] (integer array). Cut them into small pieces to guarantee you could have equal or more than k pieces with the原创 2021-05-11 16:05:36 · 129 阅读 · 0 评论 -
Lintcode1046 · Prime Number of Set Bits in Binary Representation go
/**1046 · Prime Number of Set Bits in Binary RepresentationAlgorithmsEasyAccepted Rate70%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime numbe原创 2021-05-11 15:43:04 · 101 阅读 · 0 评论 -
Lintcode168 · Burst Balloons go
/**168 · Burst BalloonsAlgorithmsHardAccepted Rate51%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the原创 2021-05-10 19:13:11 · 117 阅读 · 0 评论 -
Lintcode154 · Regular Expression Matching go
/**154 · Regular Expression MatchingAlgorithmsHardAccepted Rate31%DescriptionSolutionNotesDiscussLeaderboardDescriptionImplement regular expression matching with support for ‘.’ and ‘*’.‘.’ Matches any single character.‘*’ Matches zero or more of原创 2021-05-08 15:06:47 · 108 阅读 · 0 评论 -
Lintcode1892 · Mine-sweeping go
/**1892 · Mine-sweepingAlgorithmsMediumAccepted Rate36%DescriptionSolutionNotesDiscussLeaderboardDescriptionIt’s an easy mine-sweeping game.You are given a n*m matrix as the map of game.Each position has a value (0 or 1, 1 means there is no thunde原创 2021-05-07 14:54:28 · 162 阅读 · 0 评论 -
Lintcode 1891 · Travel Plan go
/**1891 · Travel PlanAlgorithmsMediumAccepted Rate60%DescriptionSolutionNotesDiscussLeaderboardDescriptionThere are n cities, and the adjacency matrix arr represents the distance between any two cities.arr[i][j] represents the distance from city i原创 2021-05-06 19:38:19 · 159 阅读 · 0 评论 -
Lintcode1890 · Form Minimum Number go
/**1890 · Form Minimum NumberAlgorithmsMediumAccepted Rate61%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven a pattern str containing only I and D. I for increasing and D for decreasing. Please design an algorithm to return the string th原创 2021-04-30 15:01:51 · 140 阅读 · 1 评论 -
Lintcode1888 · Shortest Path in Matrix go
/**1888 · Shortest Path in MatrixAlgorithmsMediumAccepted Rate44%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven the matrix of M rows and N columns, 0 represents empty space, - 1 represents obstacle, and 1 represents target points (there原创 2021-04-30 14:29:40 · 146 阅读 · 0 评论 -
Lintcode1851 · Buy Passes go
/**1851 · Buy PassesAlgorithmsMediumAccepted Rate52%DescriptionSolutionNotesDiscussLeaderboardDescriptionAlex plans on visiting the museum and is at the counter to purchase passes for the same. The administrators have decided not to sell group pass原创 2021-04-29 15:17:12 · 204 阅读 · 0 评论 -
Lintcode1833 · pen box go
/**1833 · pen boxAlgorithmsMediumAccepted Rate50%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven you an array boxes and a target. Boxes[i] means that there are boxes[i] pens in the ith box. Subarray [i, j] is valid if sum(boxes[i] + boxe原创 2021-04-29 15:04:36 · 246 阅读 · 0 评论 -
Lintcode1753 · Doing Homework go
/**1753 · Doing HomeworkAlgorithmsMediumAccepted Rate38%DescriptionSolutionNotesDiscussLeaderboardDescriptionFor n people, each of them needs to do m jobs independently.The i job takes cost[i] time. Since each person’s free time is different, the原创 2021-04-29 14:40:45 · 111 阅读 · 0 评论 -
Lintcode1736 · Throw garbage go
/**1736 · Throw garbageAlgorithmsMediumAccepted Rate51%DescriptionSolutionNotesDiscussLeaderboardDescriptionThere are n garbage bags, and the weight of each garbage bag is between [1.01, 3.00] pounds.You can take up to 3.00 pounds of garbage one t原创 2021-04-28 10:47:05 · 157 阅读 · 0 评论 -
Lintcode1511 · Mirror Reflection go
/**1511 · Mirror ReflectionAlgorithmsMediumAccepted Rate74%DescriptionSolutionNotesDiscussLeaderboardDescriptionThere is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of t原创 2021-04-27 16:02:03 · 121 阅读 · 0 评论 -
Lintcode1508 · Score After Flipping Matrix go
/**1508 · Score After Flipping MatrixAlgorithmsMediumAccepted Rate89%DescriptionSolutionNotesDiscussLeaderboardDescriptionWe have a two dimensional matrix A where each value is 0 or 1.A move consists of choosing any row or column, and toggling eac原创 2021-04-27 15:57:13 · 115 阅读 · 0 评论 -
Lintcode1499 · Reordered Power of 2 go
/**1499 · Reordered Power of 2AlgorithmsMediumAccepted Rate62%DescriptionSolutionNotesDiscussLeaderboardDescriptionStarting with a positive integer N, we reorder the digits in any order (including the original order) such that the leading digit is原创 2021-04-27 15:26:57 · 96 阅读 · 0 评论 -
Lintcode1492 · Koko Eating Bananas go
/**1492 · Koko Eating BananasAlgorithmsMediumAccepted Rate59%DescriptionSolutionNotesDiscussLeaderboardDescriptionKoko loves to eat bananas. There are N piles of bananas, the i-th pile has piles[i] bananas. The guards have gone and will come back i原创 2021-04-27 15:02:22 · 98 阅读 · 0 评论 -
Lintcode1477 · Car Fleet go
/**1477 · Car FleetAlgorithmsMediumAccepted Rate53%DescriptionSolutionNotesDiscussLeaderboardDescriptionN cars are going to the same destination along a one lane road. The destination is target miles away.Each car i has a constant speed speed[i] (原创 2021-04-27 14:44:39 · 131 阅读 · 0 评论 -
Lintcode1457 · Search Subarray go
/**1457 · Search SubarrayAlgorithmsMediumAccepted Rate40%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven an array arr and a nonnegative integer k, you need to find a continuous array from this array so that the sum of this array is k. Ou原创 2021-04-27 11:36:57 · 114 阅读 · 0 评论 -
Lintcode1448 · Card Game go
/**1448 · Card GameAlgorithmsMediumAccepted Rate34%DescriptionSolutionNotesDiscussLeaderboardDescriptionA card game that gives you the number of cards n,and two non-negative integers: totalProfit, totalCost. Then it will give you the profit value o原创 2021-04-27 11:19:49 · 119 阅读 · 0 评论 -
Lintcode1439 · Consecutive Numbers Sum go
/**1439 · Consecutive Numbers SumAlgorithmsMediumAccepted Rate50%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven a positive integer N, how many groups of continuous positive integers satisfy that the sum of all numbers is N?1 <= N &l原创 2021-04-27 10:17:12 · 141 阅读 · 0 评论 -
Lintcode1435 · Find And Replace in String go
/**1435 · Find And Replace in StringAlgorithmsMediumAccepted Rate63%DescriptionSolutionNotesDiscussLeaderboardDescriptionTo some string S, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the原创 2021-04-27 09:23:22 · 122 阅读 · 0 评论 -
Lintcode1433 · Image Overlap go
/**1433 · Image OverlapAlgorithmsMediumAccepted Rate65%DescriptionSolutionNotesDiscussLeaderboardDescriptionTwo images A and B are given, represented as binary, square matrices of the same size. (A binary matrix has only 0s and 1s as values.)We tr原创 2021-04-26 19:56:05 · 103 阅读 · 0 评论 -
Lintcode1431 · Push Dominoes go
/**1431 · Push DominoesAlgorithmsMediumAccepted Rate60%DescriptionSolutionNotesDiscussLeaderboardDescriptionThere are N dominoes in a line, and we place each domino vertically upright.In the beginning, we simultaneously push some of the dominoes e原创 2021-04-26 19:44:13 · 101 阅读 · 0 评论 -
Lintcode1602 · Decoded String at Index go
/**1602 · Decoded String at IndexAlgorithmsMediumAccepted Rate56%DescriptionSolutionNotesDiscussLeaderboardDescriptionAn encoded string S is given. To find and write the decoded string to a tape, the encoded string is read one character at a time a原创 2021-04-23 14:36:45 · 106 阅读 · 0 评论 -
Lintcode1601 · Boats to Save People go
/**1601 · Boats to Save PeopleAlgorithmsMediumAccepted Rate61%DescriptionSolutionNotesDiscussLeaderboardDescriptionThe i-th person has weight people[i], and each boat can carry a maximum weight of limit.Each boat carries at most 2 people at the sa原创 2021-04-22 19:45:38 · 118 阅读 · 0 评论 -
Lintcode1375 · Substring With At Least K Distinct Characters go
/**1375 · Substring With At Least K Distinct CharactersAlgorithmsMediumAccepted Rate45%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven a string S with only lowercase characters.Return the number of substrings that contains at least k di原创 2021-04-21 17:29:32 · 116 阅读 · 0 评论 -
LintCode1371 · Linked List Components go
/**1371 · Linked List ComponentsAlgorithmsMediumAccepted Rate66%DescriptionSolutionNotesDiscussLeaderboardDescriptionWe are given head, the head node of a linked list containing unique integer values.We are also given the list G, a subset of the v原创 2021-04-21 16:54:43 · 111 阅读 · 0 评论 -
Lintcode1357.Path Sum II go
/**1357 · Path Sum IIAlgorithmsMediumAccepted Rate78%DescriptionSolutionNotesDiscussLeaderboardDescriptionGiven a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.A leaf is a node with no children.Exam原创 2021-04-21 15:54:06 · 106 阅读 · 0 评论 -
Lintcode 161. Rotate Image go
题目链接:https://www.lintcode.com/problem/rotate-image/description/*** @param matrix: a lists of integers* @return: nothing*/func rotate (matrix *[][]int) { // write your code here if (matrix == n...原创 2020-05-07 10:41:01 · 267 阅读 · 2 评论