-
2018-07-26-回归问题
回归问题假定我们现有一大批数据,包含房屋的面积和对应面积的房价信息,如果我们能得到房屋面积与房屋价格间的关系,那么,给定一个房屋时,我们只要知道其面积,就能大致推测出其价格了。上面的问题还可以被描述为: “OK,我具备了很多关于房屋面积及其对应售价的知识(数据),再通过一定的学习,当面对新的房屋面积时,我不再对其定价感到束手无策”。通常,这类预测问题可以用回归模型(regression)进行解决,回归模型定义了输入与输出的关系,输入即现有知识,而输出则为预测。一个预测问题在回归模型下的解...…
-
189. rotate array
Given an array, rotate the array to the right by k steps, where k is non-negative.给定一个数组,将数组向右旋转k步,其中k为非负数。Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps to the right: [7,1,2,3,4,5,6]rotate 2 steps to t...…
-
第4章 numpy基础
import numpy as np# 一维a = np.array([1, 2, 3]); print(a) # [1 2 3]# 等间隔数字的数组b = np.arange(10); print(b) # [0 1 2 3 4 5 6 7 8 9] # 二维c = np.array([[1, 2], [3, 4]]); print(c) # [[1 2] # [3 4]]# ndmin指定返回数组的最小维数d = np.array([1, 2, 3, 4, 5])...…
-
171. Excel Sheet Column Number
Given a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28 ...Example 1:Input: “A”Output: 1Example 2:Input: “AB”Output: 28Example 3:Input: “ZY...…
-
第一章 准备工作
1.1 本书的内容利用Python进行数据控制、处理、整理、分析等方面的具体细节和基本要点。掌握这些,可以让你成为一个数据分析专家。重点是Python编程、库,以及用于数据分析的工具。什么样的数据?主要指的是结构化数据(structured data) 表格型数据,其中各列可能是不同的类型(字符串、数值、日期等)。比如保存在关系型数据库中或以制表符/逗号为分隔符的文本文件中的那些数据。 多维数组(矩阵)。 通过关键列(对于SQL用户而言,就是主键和外键)相互联系的多个表。 间隔平均...…
-
第2章 Python语法基础
鼓励你使用IPython shell和Jupyter试验示例代码,并学习不同类型、函数和方法的文档。虽然我已尽力让本书内容循序渐进,但读者偶尔仍会碰到没有之前介绍过的内容。本书大部分内容关注的是基于表格的分析和处理大规模数据集的数据准备工具。2.1 Python解释器Python是解释性语言。Python解释器同一时间只能运行一个程序的一条语句。标准的交互Python解释器可以在命令行中通过键入python命令打开:2.2 IPython基础运行IPython Shell运行Jupyter...…
-
155. Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() – Get the top element.getMin() – Retrieve the minimum elemen...…
-
141. Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?给定一个链表,确定它是否有一个循环。跟进:你能不用额外的空间解决它吗?思路:看最后一个结点是否指的是第一个结点。依次遍历网上思路:https://blog.csdn.net/coder_orz/article/details/51516558# Definition for s...…
-
136. Single Number.py
Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?Example 1:Input: [2,2,1]Output: 1E...…
-
122. Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times)...…
-
842操作系统复习
主要题型: **2018 ** 名词解释3T(2*3) 大题6T(4+3+3+4+4+8) 名词解释(2X3)** 1、特权指令 2、内部碎片 3、程序的局部性原理 大题 1、(4分)UNIX系统有一个主函数 main{ fork();/*<–pc(程序计数器),进程A fork(); fork(); } 问最多最多可再产生多少个进程?并画出家族树(都不懂说...…
-
121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.N...…
-
118. Pascal's Triangle
Given a non-negative integer numRows, generate the first numRows of Pascal’s triangle.In Pascal’s triangle, each number is the sum of the two numbers directly above it.给定非负整数numRows,生成Pascal三角形的第一个numRows。在Pascal的三角形中,每个数字是它上面两个数字的总和。Example:Input...…
-
python面向对象
面向过程:根据业务逻辑从上而下写代码 面向过程:对数据与函数绑定到一起,进行封装,这样可以快递进行开发1.定义类class 类名: 2.定义方法class Dog : #可以直接添加属性,会在调用类的时候直接调用该方法 def __init__(self): self.weight = 5 self.color = "黄色" #另 def __init__(self, newWeight, newColor): se...…
-
344. Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = “hello”, return “olleh”.思路:先转换成列表,然后直接通过reverse()函数来实现关键在于字符串与列表之间的相互转换class Solution(object): def reverseString(self, s): """ :type s...…
-
2018-07-17-梯度高级优化Octave实现
GNU Octave, version 4.4.0Copyright (C) 2018 John W. Eaton and others.This is free software; see the source code for copying conditions.There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY orFITNESS FOR A PARTICULAR PURPOSE. For details, ...…
-
242. Valid Anagram
Given two strings s and t , write a function to determine if t is an anagram of s.Example 1:Input: s = “anagram”, t = “nagaram”Output: trueExample 2:Input: s = “rat”, t = “car”Output: falseNote:You may assume the string contains only lowercase alp...…
-
python函数
需掌握知识点: 函数定义 函数调用 嵌套函数 全局变量,全局变量不可以修改,可以用g_a 局部变量函数例子:编写学生管理系统 使用自定义函数,完成对程序的模块化 学生信息至少包括:姓名,年龄, 学号, 除此以外,可以适当添加 必须完成的功能:添加,删除,修改,查询,退出 1. 把整体框架搞清楚,先搭建框架,不要一开始就考虑函数经过分析,应该把显示提示的代码,放到一个函数中def showInfo(): print("-"*30) print(" 学生管理系...…
-
237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Given linked list – head = [4,5,1,9], which looks like following:编写一个函数来删除单链表中的节点(尾部除外),只允许访问该节点。鉴于链表 - head = [4,5,1,9],如下所示:4 -> 5 -&g...…
-
387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples:s = “leetcode”return 0.s = “loveleetcode”,return 2.Note: You may assume the string contain only lowercase letters.思路:蛮力法遍历网...…