作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/score-after-flipping-matrix/description/ 题目描述 We have a two dimensional matrix A where each value is 0 or 1. A move consists of choosing a…
We have a two dimensional matrix A where each value is 0 or 1. A move consists of choosing any row or column, and toggling each value in that row or column: changing all 0s to 1s, and all 1s to 0s. After making any number of moves, every row of this…
We have a two dimensional matrix A where each value is 0 or 1. A move consists of choosing any row or column, and toggling each value in that row or column: changing all 0s to 1s, and all 1s to 0s. After making any number of moves, every row of this…
题目如下: 解题思路:本题需要知道一个数字规律,即pow(2,n) > sum(pow(2,0)+pow(2,1)+...+pow(2,n-1)).所以,为了获得最大值,要保证所有行的最高位是1,即需要优先进行行变换,把最高位变成1.接下来就是列变换,把0多于1的列做变换变成1多于0的列即可. 代码如下: class Solution(object): def matrixScore(self, A): """ :type A: List[List[int]] :rty…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 变长数组 求余法 维护行列 相似题目 参考资料 日期 题目地址:https://leetcode.com/problems/reshape-the-matrix/description/ 题目描述 In MATLAB, there is a very useful function called 'reshape', which can reshap…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/random-flip-matrix/description/ 题目描述: You are given the number of rows n_rows and number of columns n_cols of a 2D binary matrix where all values are initially…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/card-flipping-game/description/ 题目描述: On a table are N cards, with a positive integer printed on the front and back of each card (possibly different). We flip…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 回溯法 日期 题目地址:https://leetcode.com/problems/pyramid-transition-matrix/description/ 题目描述 We are stacking blocks to form a pyramid. Each block has a color which is a one letter str…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 迭代 递归 日期 [LeetCode] 题目地址:https://leetcode.com/problems/reverse-linked-list/ Total Accepted: 105474 Total Submissions: 267077 Difficulty: Easy 题目描述 Reverse a singly linked list.…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 日期 题目地址:https://leetcode.com/problems/maximum-binary-tree/description/ 题目描述 Given an integer array with no duplicates. A maximum tree building on this array is defined as fol…