自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(49)
  • 收藏
  • 关注

原创 机器学习吴恩达第四章 多变量线性回归

4.1 多维特征模型可以有更多的特征,而不是单一的。n代表特征的数量。X(i)代表第i个特征实例,是特征矩阵中的第i行,是个向量。代表特征矩阵中的第i行中的第j个特征。支持多变量的假设h可以表示为:有n+1个参数和n个变量,为了方便我们使x0=1,则公式转化为:此时,模型中参数为n+1维向量,特征矩阵X的维度使m*(n+1),公式可以简化为:4.2 多变量梯度下降在多变量线性回归中,我们构建一个代...

2018-07-13 22:13:19 303

原创 机器学习吴恩达第二章上 单变量线性回归

2.1 模型表示第一个算法是线性回归算法。在监督学习中,数据集被称为训练集。m代表训练样本的数目。x代表特征/输入变量y代表目标/输出变量(x,y)代表训练集中的实例(x(i),y(i))代表第i个观察实例h代表学习算法的解决方案或函数,也称为假设(hypothesis)如图所示,训练集是房屋的价格,我们输入了房屋的面积x,h表示一个函数,映射出房屋的价格y。而我们要考虑的问题是如何表达h。一种可...

2018-06-30 18:48:24 268

原创 机器学习吴恩达第一章 引言

1.1 欢迎1.2 机器学习是什么一个程序被认为能从经验E中学习,解决任务T,达到性能度量值P,当且仅当,有了经验E后,经过P评判,程序在处理T时的性能有所提升。以下棋举例,E是程序上万次的自我练习的经验;T是任务下棋;P是赢得比赛的概率。主要的两类算法为:监督学习和无监督学习。1.3 监督学习经典例子:预测房价横轴表示房子的面积,单位是平方英尺,纵轴表示房价,单位是千美元。那基于这组数据,假如你...

2018-06-28 22:23:42 385

原创 Leetcode95. Unique Binary Search Trees II

Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1

2018-01-31 14:40:37 373

原创 Leetcode96. Unique Binary Search Trees

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \

2018-01-31 11:16:23 284

原创 Leetcode94. Binary Tree Inorder Traversal

Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2]. 非常简单的中序遍历,都AC以后才弄明白说可不可以用迭代

2018-01-30 18:41:34 230

原创 Leetcode31. Next Permutation

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible o

2018-01-29 16:30:02 199

原创 Leetcode35. Search Insert Position

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.

2018-01-28 22:10:43 210

原创 剑指Offer面试题4:二维数组中的查找

在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。#includeusing namespace std;bool found(int* matrix, int rows, int columns, int num){ bool find = false; if (ma

2018-01-28 19:35:07 307

原创 剑指Offer 面试题3.数组中重复的数字

找出数组中重复的数字在一个长度为n的数组里的所有数字都在0到n-1的范围内。 数组中某些数字是重复的,但不知道有几个数字是重复的。也不知道每个数字重复几次。请找出数组中任意一个重复的数字。例如,如果输入长度为7的数组{2,3,1,0,2,5,3},那么对应的输出是重复的数字2或者3。有几个思路来解决这个问题:1.排序这是最直接的方法,然后从头到尾扫描就可以了,时间复杂度:O

2018-01-28 17:10:39 380

原创 Leetcode27. Remove Element

Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array

2018-01-26 18:56:59 214

原创 26. Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in-place such that each element appear onlyonce and return the new length.Do not allocate extra space for another array, you must do this by modifying

2018-01-26 18:49:51 190

原创 Leetcode18. 4Sum

Given an array S of n integers, are there elements a,b, c, and d in S such that a + b +c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution s

2018-01-26 18:27:57 257

原创 Leetcode16. 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly

2018-01-26 18:08:20 170

原创 Leetcode15. 3Sum

Given an array S of n integers, are there elements a,b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain du

2018-01-26 16:09:21 204

原创 Leetcode11. Container With Most Water

Given n non-negative integers a1, a2, ...,an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of linei is at (i, ai) and (i, 0). Find

2018-01-26 15:30:33 160

原创 Leetcode1.Two Sum

又回来刷题了,小一个月被各种事情耽误没有写代码,再写的时候完全手生。接下来的时间要全身心准备年后的各种内推,希望3月能去一个好公司实习。无他,唯手熟尔。这题还是挺简单的,我第一反应就是用双循环,不过确实时间效率并不高,看了一下百度上的各种答案,有的用双指针和map的hash,没太详细看,慢慢来,毕竟这种简单题命中率并不高Given an array of integers, r

2018-01-25 15:04:29 217

原创 19. Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the l

2017-12-22 17:03:18 198

原创 Leetcode21. Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example: Input: 1->2->4, 1->3->4Output: 1->1->2->3->4-

2017-12-21 22:55:50 217

原创 Leetcode237. 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.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value

2017-12-21 20:15:18 187

原创 Leetcode203. Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5 在链表中删除值为6的节点。这题调了好久,看

2017-12-21 19:59:18 160

转载 判断链表中是否有环 ----- 有关单链表中环的问题

此文为转载原文地址:https://www.cnblogs.com/dancingrain/p/3405197.html给定一个单链表,判断其中是否有环,已经是一个比较老同时也是比较经典的问题,在网上搜集了一些资料,然后总结一下大概可以涉及到的问题,以及相应的解法。首先,关于单链表中的环,一般涉及到一下问题:1.给一个单链表,判断其中是否有环的存在;2.如果存在

2017-12-21 17:24:02 160

原创 Leetcode141. 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? 判断链表是否有环问题,用快慢指针解决。如果有环,快指针和满指针一定会相遇,并且是在慢指针走完一圈之前,或者刚好走完一圈。class Solution {pu

2017-12-21 17:14:35 142

原创 Leetcode234. Palindrome Linked List

Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断链表是否是回文,第一想法是遍历一次通过相加的方式得到sum,然后同时逆置链表,之后再相加得到temp,看是否相等。代码如下:class So

2017-12-21 16:15:28 157

原创 Leetcode206. Reverse Linked List

Reverse a singly linked list.反转链表的题目,很简单,和之前刷的lintcode题目一致,还是决定刷leetcode吧,一是因为最近网速算是给力,二是锻炼一下英语能力。#includeusing namespace std;struct ListNode {int val;ListNode *next;ListNode(int x) : val(x),

2017-12-21 15:38:59 164

原创 Leetcode160. Intersection of Two Linked Lists/C++

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: a1 → a2 ↘

2017-12-20 16:56:26 204

原创 Lintcode 35.翻转链表

样例给出一个链表1->2->3->null,这个翻转后的链表为3->2->1->null挑战在原地一次翻转完成/** * Definition of ListNode * * class ListNode { * public: * int val; * ListNode *next; * * ListNode(int v

2017-12-13 16:41:27 244

原创 PAT_乙级1016

1016. 部分A+B (15)时间限制100 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA。例如:给定A = 3862767

2017-08-04 17:05:47 333

转载 C++Vector用法

C++内置的数组支持容器的机制,但是它不支持容器抽象的语义。要解决此问题我们自己实现这样的类。在标准C++中,用容器向量(vector)实现。容器向量也是一个类模板。标准库vector类型使用需要的头文件:#include 。vector 是一个类模板。不是一种数据类型,vector是一种数据类型。Vector的存储空间是连续的,list不是连续存储的。一、 定义和初始化vector

2017-08-02 20:20:49 198

原创 PAT_乙级1014

1014. 福尔摩斯的约会 (20)时间限制100 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue大侦探福尔摩斯接到一张奇怪的字条:“我们约会吧! 3485djDkxh4hhGE 2984akDfkk

2017-08-02 17:18:48 329

原创 PAT_乙级1012

1012. 数字分类 (20)时间限制100 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字:A1 = 能被5整除的数字中所有偶数的

2017-07-31 17:48:09 498

原创 PAT_乙级1010

1010. 一元多项式求导 (25)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard设计函数求一元多项式的导数。(注:xn(n为整数)的一阶导数为n*xn-1。)输入格式:以指数递降方式输入多项式非零项系数和指数(绝对值

2017-07-30 21:17:57 444

原创 PAT_乙级1003

#include#include#includeusing namespace std;int main(){ char s[110]; int n; scanf("%d\n",&n); int count_a,count_p,count_t; int pos_p,pos_t; int i; while(n--) { count_a=count_p=count_t=p

2017-07-23 23:05:21 245

原创 PAT_乙级1009

1009. 说反话 (20)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。输入格式:测试输入包含一个测试用例,在一行

2016-02-13 23:38:11 333

原创 PAT_乙级1008

1008. 数组元素循环右移问题 (20)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard一个数组A中存有N(N>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M>=0)个位置,即将A中的数据由(A0A1……

2016-02-13 23:04:25 1664 2

原创 PAT_乙级1005

1005. 继续(3n+1)猜想 (25)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue卡拉兹(Callatz)猜想已经在1001中给出了描述。在这个题目里,情况稍微有些复杂。

2016-02-13 22:30:47 1482

转载 c++中sort()及qsort()的用法总结

想起来自己天天排序排序,冒泡啊,二分查找啊,结果在STL中就自带了排序函数sort,qsort,总算把自己解脱了~所以自己总结了一下,首先看sort函数见下表:  函数名 功能描述  sort 对给定区间所有元素进行排序  stable_sort 对给定区间所有元素进行稳定排序  partial_sort 对给定区间所有元素部分排序  partial_sort_copy

2016-02-13 14:56:47 326

原创 PAT_乙级1004

1004. 成绩排名 (20)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue读入n名学生的姓名、学号、成绩,分别输出成绩最高和成绩最低学生的姓名和学号。输入格式:每个测试输入包

2016-02-11 20:16:30 344

原创 PAT_乙级1002

1002. 写出这个数 (20)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue读入一个自然数n,计算其各位数字之和,用汉语拼音写出和的每一位数字。输入格式:每个测试输入包含1个

2016-02-11 18:51:02 596

原创 PAT_乙级1046

1046. 划拳(15)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue划拳是古老中国酒文化的一个有趣的组成部分。酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字。如

2016-02-10 19:33:55 328

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除