- 博客(49)
- 资源 (4)
- 收藏
- 关注
原创 算法:快速排序的实现
理解:快速排序对问题分而治之的一种方法,在每一趟排序后,都能确定一个数的位置(即分割点),因此快速排序的核心是确定分割点的位置并把数组按大小分在分割点的两侧。因此快排可以分为两部分,第一部分是递归处理问题,第二部分是找到分割点第一部分:def quickSort(l, r): if l >=r: return p = partition(nums, l, r...
2019-07-03 00:48:33
353
原创 Search in Rotated Sorted Array
题目Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to search. If found...
2019-04-12 01:23:53
259
原创 leetcode刷题:Linked List Cycle II (链表循环 II) 详解
原题题目链接Given a linked list, return the node where the cycle begins. If there is no cycle, return null.To represent a cycle in the given linked list, we use an integer pos which represents the positi...
2019-02-28 19:24:19
430
原创 Group Anagrams
题目Given an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ ["ate","eat","tea"], ["nat"
2019-02-21 19:31:13
226
原创 Combination Sum
题目Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.The same repe...
2019-02-20 21:53:39
130
原创 Palindromic Substrings
题目Given a string, your task is to count how many palindromic substrings in this string.The substrings with different start indexes or end indexes are counted as different substrings even they consis...
2019-01-17 15:27:02
148
原创 机器学习(西瓜书)8.3式证明
书上列出了这个式子,但是没有给出详细的证明根据书上的提示,找到Hoeffding的定义对于二项分布,有如下定义:假设为抛硬币的情况,每次正面朝上的概率设为p,抛n次硬币,正面朝上次数不超过k次的概率为:对于ε > 0,当k = (p − ε)n时,以下不等式成立(Hoeffding不等式)回到8.3式中等价于T个基分类器中,最多有T/2个分类器分类正确。这样整体分类就错误...
2018-12-26 16:55:25
1072
原创 DI String Match
题目Given a string S that only contains “I” (increase) or “D” (decrease), let N = S.length.Return any permutation A of [0, 1, …, N] such that for all i = 0, …, N-1:If S[i] == “I”, then A[i] < A[i+...
2018-12-15 22:41:08
192
原创 Find All Numbers Disappeared in an Array
题目Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Cou...
2018-10-25 01:07:06
145
原创 Find the Difference
题目Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was a...
2018-10-09 21:19:48
560
原创 uess Number Higher or Lower
题目We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number is higher...
2018-10-09 20:47:02
149
原创 Palindrome Linked List
题目Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: true总结思路:这题的关键是找到链表的中间节点(medium)用slow和fast两个指...
2018-09-22 19:47:18
143
原创 Reverse Linked List
题目Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULL总结思路一:递归,从后往前反转代码:# Definition for singly-linked list.# class ListNo...
2018-09-21 14:26:09
131
原创 Isomorphic Strings
题目Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with anot...
2018-09-14 10:46:27
139
原创 Count Primes
题目Count the number of prime numbers less than a non-negative number, n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.总结思路一:判断每一个数是不...
2018-09-13 00:09:40
128
原创 Happy Number
题目Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squar...
2018-09-12 00:10:28
325
原创 Factorial Trailing Zeroes
题目Given an integer n, return the number of trailing zeroes in n!.Example 1:Input: 3Output: 0Explanation: 3! = 6, no trailing zero.Example 2:Input: 5Output: 1Explanation: 5! = 120, one tra...
2018-09-08 21:04:48
148
原创 Majority Element
题目Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element ...
2018-09-07 19:27:38
133
原创 Intersection of Two Linked Lists
题目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 ↘ ...
2018-09-06 14:51:12
123
原创 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?总结我的代码:public class Solution { public boolean hasCycle(ListNode head) ...
2018-09-04 22:31:05
121
原创 Pascal's Triangle II
题目Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal’s triangle.Note that the row index starts from 0. In Pascal’s triangle, each number is the sum of the two numbe...
2018-09-03 23:41:55
130
原创 Minimum Depth of Binary Tree
题目Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A leaf is a node with no chi...
2018-09-01 01:06:44
109
原创 Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never diffe...
2018-08-31 01:19:20
113
原创 Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3,9,20,null,null,15...
2018-08-30 11:53:38
138
原创 Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no childre...
2018-08-29 23:58:37
160
原创 Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume tha...
2018-08-29 00:42:26
117
原创 Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and only...
2018-08-28 00:04:14
323
原创 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defin...
2018-08-25 17:32:58
147
原创 Maximum Subarray
题目: Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Expl...
2018-08-25 00:16:14
137
原创 ubuntu配置tensorflow-gpu运行环境的配置
配置tensorflow-gpu需要安装如下内容: cuda-driver : 显卡驱动 cuda : 相当于是一种计算方法 cudnn :这个是一个工具,用来处理cuda的 tensorflow-gpu : 一定要是gpu版本 我的理解可能是错的,但是上面这几个东西是一定要装好的装上面的东西,版本兼容性非常重要,否则很可能不能运行。 我装的是: cuda-driver :375...
2018-08-11 14:22:34
554
原创 MAC下mysql的安装配置
1、下载安装进入官网.先去下载mysql-5.7.9-osx10.9-x86_64.dmg 安装(一直下一步,注意,要错过了密码提示,记录下密码)mysql-5.7.9-osx10.9-x86_64.pkg好了,2、启动MySQL服务.点击系统偏好设置,打开mysql,点击start3、配置环境变量1.打开终端,输入: cd ~ 会进入~文件夹 touch .bash_profile 回
2017-01-10 13:27:38
374
原创 eclispe工程没有编译的解决办法
eclipse中碰到java文件没有编译的问题,通常由二个地方引起: 1、java compiler选项的设置 这里的问题大多是选项漏选,导致部分代码修改后不会重新编译。 2、java build path选项的设置 这里的问题大多类似上面描述的,jar文件引用错误或jre版本不对等等。具体java compiler和java buil
2016-12-29 16:54:39
723
转载 git设置http连接用户名密码
转载连接摘要: git在更新文件时都需要输入账号和密码,在维护多个库时比较麻烦。可以通过简单的设置即可存储使用以前的参数设置。如果需要多个账号,还可以通过pygit写个脚本来解决。 linux下在~/下, touch创建文件 .git-credentials: touch .git-credentials用vim编辑此文件, vim .git-credentials输入内容格式 https:
2016-10-18 10:19:06
10061
原创 effective java-类和接口
前言本部分总结effective java第四章类和接口的内容。条例封装的重要性:它可以有效地解除组成系统的各个模块之间的耦合关系,使这些模块可以独立的开发、测试、优化、使用、理解和修改。尽可能地使每个类或者成员不被外界访问。 如果一个类可以声明为包级私有,那么就应该声明为包私有的,使之成为包的一部分,而不是API的一部分。 如果一个包私有的顶层类或接口只被一个类使用,那么久应该考虑让这个类
2016-07-11 14:25:33
341
原创 mysql事务管理
前言加深记忆mysql事务四个要点:transaction 事务roolback 回退commit 提交savepoint 保留点注*:在事务提交或回滚后,事务会自动关闭。(默认情况下更改会自动提交)标识事务的开始start transaction;回退事务rollback;提交事务commit;保留点设置保留点:savepoint mypoint;回退到保留点:rollback to m
2016-07-07 17:45:47
324
原创 mysql基本操作一览
前言因为有些不常用的操作总是用完就忘,每次在使用时又要上网查,查到的还很难第一条就是适用的,所以自己总汇下mysql的一些基础操作,方便查阅也加深记忆。这里介绍所有基础的表操作,包括,修改表结构,增删改查,表联结,分组等等。注意,大部分情况下只介绍写法,而不介绍功能。关于存储过程、索引等会在以后介绍创建表CREATE TABLE [IF NOT EXISTS] customers( cu
2016-07-04 16:14:47
302
原创 Spring整合Mybatis简要概括
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.
2016-06-24 14:10:53
464
原创 Spring注解-@ModelAttribute
适用范围方法参数标注在方法上@ModelAttribute标注在方法上时表明这个方法是用于给Model模型添加一个或多个属性。 标注了@ModelAttribute的方法会在访问@RequestMapping方法前先执行(同一个类中),这个方法通常用于参加通用的属性。 一个类中可以有任意个@ModelAttribute标注的方法,它们都会在这个类的@RequestMapping方法前执行
2016-06-24 11:05:14
376
原创 SpringMVC总结之配置
前言SpringMVC的核心是前端控制器,关于Springmvc不再介绍。搭建SpringMVC第一步: 在web.xml中配置前端控制器<servlet> <servlet-name>spitter</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet
2016-06-23 14:46:32
478
华为杯研究生数模竞赛2017年试题
2018-09-10
stackGan论文
2018-08-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人