自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LaiCode 82. Remove Adjacent Repeated Characters IV

LaiCode 82. Remove Adjacent Repeated Characters IV题目思路First, we need a stack to store elements which need to be in the output.Then we need to put the string into a character array, and traverse the whole array. In the meanwhile, we need to put unique

2021-07-02 22:09:53 161

原创 LaiCode 395.Remove Certain Characters

LaiCode 395.Remove Certain Characters题目思路First we need to change the input string into a character array and put the string t into a Hashset.Then we need to set two pointers, slow and fast, to traverse the character array. The fast pointer will go th

2021-07-02 15:55:57 134

原创 167. Two Sum II - Input array is sorted

刷题笔记167. Two Sum II - Input array is sorted题目Given an array of integers numbers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.Return the indices of the two numbers (1-indexed) as an intege

2021-05-05 23:55:28 85

原创 162. Find Peak Element

刷题笔记162. Find Peak Element题目A peak element is an element that is strictly greater than its neighbors.Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks.You

2021-05-05 17:43:08 76

原创 154. Find Minimum in Rotated Sorted Array II

刷题笔记154. Find Minimum in Rotated Sorted Array II题目Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become:[4,5,6,7,0,1,4] if it was rotated 4 times.[0,1,4,4,5,

2021-05-04 23:22:33 58

原创 153. Find Minimum in Rotated Sorted Array

刷题笔记153. Find Minimum in Rotated Sorted Array题目Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become:[4,5,6,7,0,1,2] if it was rotated 4 times.[0,1,2,4,5,6,7

2021-05-04 20:34:30 43

原创 81. Search in Rotated Sorted Array II

刷题笔记81. Search in Rotated Sorted Array II题目There is an integer array nums sorted in non-decreasing order (not necessarily with distinct values).Before being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.lengt

2021-05-04 15:47:41 69

原创 33. Search in Rotated Sorted Array

刷题笔记33. Search in Rotated Sorted Array题目There is an integer array nums sorted in ascending order (with distinct values).Prior to being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.length) such that the resul

2021-05-04 09:42:39 49

原创 240. Search a 2D Matrix II

刷题笔记240. Search a 2D Matrix II题目Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in each column a

2021-05-02 23:31:19 57

原创 34. Find First and Last Position of Element in Sorted Array

刷题笔记34. Find First and Last Position of Element in Sorted Array题目Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.If target is not found in the array, return [-1, -1].Follow up: C

2021-05-02 22:54:02 45

原创 74. Search a 2D Matrix

刷题笔记74. Search a 2D Matrix题目Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is greater than the last i

2021-05-01 23:27:38 68

原创 69. Sqrt(x)

刷题笔记69. Sqrt(x)题目Given a non-negative integer x, compute and return the square root of x.Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.思路用二分法思想,开跟的数一定在1和x之间(除0之外),那么这是一个在1

2021-05-01 23:18:51 61

原创 50. Pow(x, n)

刷题笔记50. Pow(x, n)题目Implement pow(x, n), which calculates x raised to the power n (i.e., xn).思路我原本的思路是常规的递归,递归n - 1。其实原理上没有问题,但是实际在很大幂次的时候会导致消耗内存过大,导致栈溢出。如下class Solution { public double myPow(double x, int n) { if (n == 0) return 1;

2021-05-01 19:07:31 83

原创 35. Search Insert Position

刷题笔记35. Search Insert Position题目Given a sorted array of distinct integers 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.思路我的思路比较繁琐,首先是判断如果target大于最大的,就直接返回最大坐标+1;

2021-05-01 17:45:25 83

原创 15. 3Sum

刷题笔记15. 3Sum题目Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.Notice that the solution set must not contain duplicate triplets.思路又是一道没自己做出来的

2021-04-30 23:33:54 74 1

原创 11. Container With Most Water

刷题笔记11. 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 the line i is at (i, ai) and (i, 0). Find two lines, which, t

2021-04-30 18:30:00 92 1

原创 1561. Maximum Number of Coins You Can Get

刷题笔记1561. Maximum Number of Coins You Can Get题目There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:In each step, you will choose any 3 piles of coins (not necessarily consecutive).Of your choice, Alice

2021-04-30 16:54:48 108 1

原创 1. Two Sum

刷题笔记1.Two Sum题目Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.You may assume that each input would have exactly one solution, and you may not use the same element twice.You can

2021-04-28 21:28:38 58

原创 1370. Increasing Decreasing String

刷题笔记1370. Increasing Decreasing String题目(这是一道虚假的easy题)Given a string s. You should re-order the string using the following algorithm:Pick the smallest character from s and append it to the result.Pick the smallest character from s which is greater tha

2021-04-27 18:36:53 86

原创 1630. Arithmetic Subarrays

刷题笔记1630. Arithmetic Subarrays题目A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence s is arithmetic if and only if s[i+1] -

2021-04-27 16:30:34 84

原创 1305. All Elements in Two Binary Search Trees

刷题笔记1305. All Elements in Two Binary Search Trees题目Given two binary search trees root1 and root2.Return a list containing all the integers from both trees sorted in ascending order.思路首先想到要把两个树中的元素全部取到一个list中,然后对这个list进行排序并返回即可。取树元素可以利用递归思想,对两个树分别递

2021-04-26 22:04:07 63

原创 1329. Sort the Matrix Diagonally

刷题笔记1329. Sort the Matrix Diagonally题目A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix’s end. For example, the matrix dia

2021-04-25 12:57:17 76

原创 1637. Widest Vertical Area Between Two Points Containing No Points

刷题笔记1637. Widest Vertical Area Between Two Points Containing No Points题目Given n points on a 2D plane where points[i] = [xi, yi], Return the widest vertical area between two points such that no points are inside the area.A vertical area is an area of fi

2021-04-24 19:37:43 119

原创 1528. Shuffle String

刷题笔记1528. Shuffle StringGiven a string s and an integer array indices of the same length.The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.Return the shuffled string.思路首先这个问题将涉及三个数据

2021-04-23 22:03:37 66

原创 1833. Maximum Ice Cream bars

刷题日记1833. Maximum Ice Cream barsIt is a sweltering summer day, and a boy wants to buy some ice cream bars.At the store, there are n ice cream bars. You are given an array costs of length n, where costs[i] is the price of the ith ice cream bar in coins.

2021-04-23 21:13:09 205

原创 基于Octave/Matlab的二元逻辑回归(logistic regression)算法

基于Octave/Matlab的二元逻辑回归(logistic regression)算法本博文基于吴恩达老师的机器学习网课,是对作业代码进行简化和补充完整后的实现。逻辑回归算法的基本思想sigmoid函数在分类问题中,我们需要根据变量x来确定变量y的种类(离散的值),这种分类问题的算法称之为逻辑回归算法。在最简单的二元逻辑分类问题中,我们将y分为两类,并分别赋值0和1来区分。0表示负向类...

2020-04-14 22:34:27 2641 2

原创 基于Octave/Matlab的梯度下降算法—单变量线性回归问题

基于Octave/Matlab的梯度下降算法——单变量线性回归问题的编程实现(吴恩达机器学习)本实验基于吴恩达老师的机器学习课程课后作业,并进行了实现,理解和再整理。梯度下降算法的基本思想代价函数表达式: J用以表示回归函数与实例之间偏差程度。而在编程中的一大思想是实现向量化,即用向量和矩阵的相乘来实现基本计算。例如模拟的线性回归方程就可以用theta矩阵的转置和X矩阵相乘来表示...

2020-04-06 17:30:53 558

原创 Octave基本操作(一)

@Octave基本操作Octave的基本操作1(吴恩达机器学习)本博客用于总结记录机器学习新手在学习吴恩达老师的机器学习网课过程中的实践操作基本逻辑运算下面是基础的逻辑运算加减乘除和幂次运算1.加法运算,直接在命令行键入所需要进行的加法运算,回车得到结果。减法运算同理2.乘除运算:3.幂次运算逻辑运算1.判断,正误直接用1或0来表示。应注意,在octave中,不等于的符...

2020-04-04 17:31:47 716

空空如也

空空如也

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

TA关注的人

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