码迷,mamicode.com
首页 >  
搜索关键字:part solution    ( 14980个结果
Learning the "PEP 8 -- Style Guide for Python Code" - part 1
PEP 8 -- Style Guide for Python Code Tabs or Spaces? Spaces are the preferred indentation method. Tabs should be used solely to remain consistent with ...
分类:编程语言   时间:2020-11-17 13:01:45    阅读次数:27
20.11.9 leetcode973
题意:给出多个二维点,求离原点最近的k个点 直接根据距离排序即可,主要看下代码,leetcode这种写法很不熟。 class Solution { public: static bool cmp(const vector<int>& a,const vector<int>& b){ return a ...
分类:其他好文   时间:2020-11-13 13:22:48    阅读次数:28
水域大小
经典dfs将当前位置传入,标记和当前点一类的点,同时进行计数 class Solution { public int[] pondSizes(int[][] land) { List<Integer> res = new LinkedList<>(); int m = land.length,n = ...
分类:其他好文   时间:2020-11-13 13:11:37    阅读次数:9
剑指 Offer 47. 礼物的最大价值
思路 比较明显的动态规划问题。状态转移方程为:f(x, y) = grid(x,y) + max {f(x-1,y), f(x, y-1)} 。 优化:这里不使用额外的数组f,而就地更改grid数组,可以将空间复杂度降为O(1)。 1 class Solution { 2 public: 3 int ...
分类:其他好文   时间:2020-11-13 13:08:20    阅读次数:7
LeetCode #55 Jump Game
###题目 Jump Game ###解题方法 这道题可以用贪心算法的思想解决,类似于Jump Game II。 ###代码 class Solution: def canJump(self, nums: List[int]) -> bool: curEnd = 0 curFarthest = 0 ...
分类:其他好文   时间:2020-11-12 13:58:21    阅读次数:5
题解 P5234 【[JSOI2012]越狱老虎桥】
题目链接 Solution [JSOI2012]越狱老虎桥 题目大意:给定一张带权无向图,你可以任意添加一条边,求权值最小的割边的最大值 Tarjan,贪心 分析: 我们先考虑是一棵树的情况,显然每一条边都是割边,我们添加一条边可以产生一个简单环,那么环上的所有边就都不是割边了 考虑贪心,我们将边权 ...
分类:Web程序   时间:2020-11-11 16:51:13    阅读次数:77
LeetCode:236 二叉树的最近公共祖先
class Solution { private TreeNode res = null; public boolean dfs(TreeNode root,TreeNode p,TreeNode q){ if(root==null){ return false; } boolean lchild ...
分类:其他好文   时间:2020-11-11 16:27:40    阅读次数:8
5516. 警告一小时内使用相同员工卡大于等于三次的人
class Solution { public: vector<string> alertNames(vector<string>& keyName, vector<string>& keyTime) { map<string, set<string> > mp; int n = keyName.s ...
分类:其他好文   时间:2020-11-11 16:23:51    阅读次数:7
LeetCode 24. 两两交换链表中的节点
class Solution { public ListNode swapPairs(ListNode head) { ListNode dummy = new ListNode(-1); ListNode p = dummy; dummy.next = head; while(p != null ...
分类:其他好文   时间:2020-11-10 11:12:58    阅读次数:4
冒泡排序(C、Python)
BEGIN: 1、冒泡排序思想(升序排序): 如 a=[9,6,8,7,5,3] i=0 第一趟排序:3与5比较,3和5交换位置,a=[9,6,8,7,3,5]; j=len-1 3与7比较,3和7交换位置,a=[9,6,8,3,7,5]; j=len-2 3与8比较,3和8交换位置,a=[9,6, ...
分类:编程语言   时间:2020-11-10 10:30:08    阅读次数:7
14980条   上一页 1 ... 40 41 42 43 44 ... 1498 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!