题目描述 打乱一个没有重复元素的数组。 示例: // 以数字集合 1, 2 和 3 初始化数组。 int[] nums = {1,2,3}; Solution solution = new Solution(nums); // 打乱数组 [1,2,3] 并返回结果。任何 [1,2,3]的排列返回的概 ...
分类:
编程语言 时间:
2020-07-11 13:04:09
阅读次数:
49
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. Th ...
分类:
其他好文 时间:
2020-07-11 12:41:31
阅读次数:
54
1329. 将矩阵按对角线排序 暴力即可,因为满足i-j的值都是相等的是复合题意的,所以我们每次将i-j相同的存入数组,然后sort排序,将原来对角线数组更新为拍完数之后的数组 class Solution { public: vector<vector<int>> diagonalSort(vec ...
分类:
编程语言 时间:
2020-07-11 12:34:20
阅读次数:
55
传送门:题目39 题目40 我觉得比较好的题解:https://leetcode-cn.com/problems/combination-sum/solution/hui-su-suan-fa-jian-zhi-python-dai-ma-java-dai-m-2/ 观察发现[2 2 3]、[2 3 ...
分类:
其他好文 时间:
2020-07-11 12:29:36
阅读次数:
68
给定一个整数数组,其中第 i 个元素代表了第 i 天的股票价格 。? 设计一个算法计算出最大利润。在满足以下约束条件下,你可以尽可能地完成更多的交易(多次买卖一支股票): 你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 卖出股票后,你无法在第二天买入股票 (即冷冻期为 1 天)。 示 ...
分类:
其他好文 时间:
2020-07-11 09:27:21
阅读次数:
49
昨晚安装pymssql时,失败了,提示pip版本需要升级: 下面是升维pip: python -m pip install --upgrade pip。 ...
分类:
编程语言 时间:
2020-07-10 10:02:36
阅读次数:
54
Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binar ...
分类:
其他好文 时间:
2020-07-10 09:54:38
阅读次数:
54
给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有满足条件且不重复的三元组。 注意:答案中不可以包含重复的三元组。 class Solution: def threeSum(self, nums: List[i ...
分类:
其他好文 时间:
2020-07-10 09:45:17
阅读次数:
54
题目描述: 方法一:动态规划 O(n2) ->O(mn) m为字典中单词最大长度 class Solution: def respace(self, dictionary: List[str], sentence: str) -> int: d = {}.fromkeys(dictionary) n ...
分类:
其他好文 时间:
2020-07-10 09:34:14
阅读次数:
44
在原有重量基础上增加一种重量的砝码,依次使用0,..., m【i】个,得到新的重量,将这些重量添加到集合中,继续重复。 import java.util.*; public class Main { static int solution(int n, int[] m, int[] x){ Set< ...
分类:
其他好文 时间:
2020-07-09 19:21:46
阅读次数:
52