码迷,mamicode.com
首页 >  
搜索关键字:solution upgrade    ( 13024个结果)
974. 和可被 K 整除的子数组
方法一:不用统计前缀和,只需要统计前i个数的余数就可以,若之前和的余数和当前和的余数相等则子数组可以整除K,遍历一遍即可 class Solution { public int subarraysDivByK(int[] A, int k) { int n = A.length; Map<Integ ...
分类:编程语言   时间:2020-07-15 23:41:52    阅读次数:64
leetcode227基本计算器II (Medium)
题目来源:leetcode227基本计算器II 题目描述: 实现一个基本的计算器来计算一个简单的字符串表达式的值。 字符串表达式仅包含非负整数,+, - ,*,/ 四种运算符和空格 。 整数除法仅保留整数部分。 示例 1: 输入: "3+2*2" 输出: 7 示例 2: 输入: " 3/2 " 输出 ...
分类:其他好文   时间:2020-07-15 23:40:20    阅读次数:78
0~n-1中缺失的数字
解法:分情况:1、缺开头。 2、缺的元素在中间部位。 3、缺的元素在最后一个位置。 class Solution { public int missingNumber(int[] nums) { int len=nums.length; for(int i=1;i<len;i++){ if(nums ...
分类:其他好文   时间:2020-07-15 23:17:24    阅读次数:73
2020.7.15 刷
96. 不同的二叉搜索树 自己用dp写的哈哈哈不是很整洁 class Solution { public int numTrees(int n) { int[] res = new int[n + 1]; if(n == 1)return 1; if(n == 2)return 2; res[0] ...
分类:其他好文   时间:2020-07-15 23:10:11    阅读次数:58
面试题 16.07. 最大数值
地址:https://leetcode-cn.com/problems/maximum-lcci/ <?php /** 编写一个方法,找出两个数字a和b中最大的那一个。不得使用if-else或其他比较运算符。 示例: 输入: a = 1, b = 2 输出: 2 */ class Solution ...
分类:其他好文   时间:2020-07-15 22:43:51    阅读次数:79
礼物的最大价值
经典dp问题 class Solution { public int maxValue(int[][] grid) { int m=grid.length,n=grid[0].length; for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ if(i==0&&j ...
分类:其他好文   时间:2020-07-15 15:48:57    阅读次数:52
CentOS7 安装pip/pip3
一、python21.安装源 yum -y install epel-release2.安装pip yum install python-pip3.对安装好的pip进行升级 pip install --upgrade pip (注意是两个短横线--)到这里pip 安装完成,即/usr/bin 目录下 ...
分类:其他好文   时间:2020-07-15 01:23:45    阅读次数:76
leetcode-----79. 单词搜索
链接:https://leetcode-cn.com/problems/word-search/ 代码 class Solution { public: bool exist(vector<vector<char>>& board, string word) { for (int i = 0; i ...
分类:其他好文   时间:2020-07-14 21:55:49    阅读次数:84
leetcode-----75. 颜色分类
链接:https://leetcode-cn.com/problems/sort-colors/ 代码 class Solution { public: void sortColors(vector<int>& nums) { for (int i = 0, j = 0, k = nums.size ...
分类:其他好文   时间:2020-07-14 18:45:30    阅读次数:62
549. 二叉树中最长的连续序列
class Solution { public int longestConsecutive(TreeNode root) { dfs(root); return res; } private int res = 0; public int[] dfs(TreeNode root) { // 以ro ...
分类:其他好文   时间:2020-07-14 18:25:06    阅读次数:49
共13024条   上一页 1 ... 65 66 67 68 69 ... 1303 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!