ICode9

精准搜索请尝试: 精确搜索
  • Python实现斐波那契数列,九九乘法表,金字塔方法。2019-09-03 18:55:22

    斐波那契数列递归实现,写法最简洁,但是效率最低,会出现大量的重复计算 def function(n): assert n >= 0, 'n > 0' if n<= 1: return n return function(n-1) + function(n-2)print(function(4))for i in range(0,20): print(function(i),end=',') 递推法,递推法,

  • python7.4.2二叉树路径问题及LeetCode题目解析2019-08-05 10:56:05

      下面题目中的路径,定义有所延伸,在解法思路及时间空间复杂度上有所挑战。  437. Path Sum III  You are given a binary tree in which each node contains an integer value.  Find the number of paths that sum to a given value.  The path does not need to start

  • 洛谷P2802题解2019-07-27 15:43:03

    一. 这个题目其实就是简单的DFS运用遍历所有条件即可但是有几点需要注意的地方 1.退出条件需要注意,一开始我设置了一个极大数来退出,后面发现完全没有必要,只需要设置大于N*M,F==0和sum》sums及可。 2. 要先判断血量在来判断目标位置上有什么东西。 只要注意一下,然后直接暴搜

  • 装饰器加参数2019-07-08 14:03:06

    import timedef logger(flag): def show_time(f): #装饰器函数 def inner(*x,**y): #闭包函数 stat = time.time() f(*x,**y) end = time.time() print('spend %s' % (end - stat)) if fl

  • 校招真题练习004 给定整数序列求连续子串最大和(滴滴)2019-06-27 09:39:39

    给定整数序列求连续子串最大和 题目描述 给定无序整数序列,求连续子串最大和,例如{-23 17 -7 11 -2 1 -34},子串为{17,-7,11},最大和为21 输入描述: 输入为整数序列,数字用空格分隔,如:-23 17 -7 11 -2 1 -34输出描述:输出为子序列的最大和:21 1 import sys 2 num = list(map(int,input()

  • 求解奖学金问题(贪心)2019-06-05 22:03:36

    /*问题描述:有n门课(编号为0~n-1),每门课都有考试。为了拿到奖学金,必须满足所有课程平均成绩至少为avg。每门课由平时成绩和考试成绩相加得到,满足为r。现知道每门课平均成绩ai(0<=i<=n-1),若想让这门课多考一分,需要花bi的时间复习。同时,也可能出现复习再多也不会超过满分的分数。为了拿到奖

  • 基础数据算法--更新中2019-05-22 14:50:06

    排序算法 冒泡排序 原理:通过不断与相邻比较,交换位置,实现排序,其重复次数为排序的长度减一。 ls = list(range(90)) random.shuffle(ls) print(ls) [53, 24, 22, 30, 58, 3, 83, 14, 45, 85, 43, 13, 66, 68, 63, 54, 38, 37, 86, 31, 15, 47, 17, 55, 81, 44, 84, 29, 20, 3

  • mxnet尝试2019-05-11 21:39:27

    http://mxnet.incubator.apache.org/versions/master/install/index.html?platform=Windows&language=R&processor=CPU 1 cran <- getOption("repos")2 cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.co

  • Sums of Digits CodeForces - 509C (贪心,模拟)2019-04-18 20:42:53

    大意: 一个未知严格递增数组$a$, 给定每个数的数位和, 求$a[n]$最小的数组$a$   #include <iostream>#include <algorithm>#include <cstdio>#include <math.h>#include <set>#include <map>#include <queue>#include <string>#include <string.h>

  • UVA11997 K Smallest Sums2019-04-10 10:40:15

    思路 经典的k路归并问题 问题先转换为2路的有序表归并 先让A[1~k]都和B[1]相加,然后加入堆中,取出堆顶(A[x]+B[y])之后,再放入A[x]+B[y+1] 代码 #include <cstdio> #include <cstring> #include <algorithm> #include <queue> using namespace std; struct QNode{ int val,s; bo

  • Weekly Contest 1292019-03-24 14:52:55

    1020. Partition Array Into Three Parts With Equal Sum Given an array A of integers, return true if and only if we can partition the array into three non-empty parts with equal sums. Formally, we can partition the array if we can find indexes i+1 < j 

  • leetcode10122019-03-17 13:39:55

    1 class Solution: 2 def bitwiseComplement(self, N: int) -> int: 3 if N==0: 4 return 1 5 elif N==1: 6 return 0 7 8 s = list() 9 while N!=0:10 re = N%211 if re==0:12

  • leetcode个人题解——#39 Combination Sum2019-03-02 19:39:45

    思路:先对数据进行排序(看评论给的测试数据好像都是有序数组了,但题目里没有给出这个条件),然后回溯加剪枝即可。 class Solution {public: int size = 0; vector<vector<int>> ans; void search(int pos, vector<int>& candidates, int target, vector<int>& res, int sums){

  • #Leetcode# 373. Find K Pairs with Smallest Sums2019-02-06 11:41:49

    https://leetcode.com/problems/find-k-pairs-with-smallest-sums/   You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from the first array and one element from th

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有