自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(31)
  • 资源 (1)
  • 收藏
  • 关注

原创 LeetCode 1262. Greatest Sum Divisible by Three DP坑

Given an arraynumsof integers, we need to find the maximum possible sum of elements of the array such that it is divisible by three.Example 1:Input: nums = [3,6,5,1,8]Output: 18Explanation: Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum su...

2020-06-30 13:35:51 318

原创 LeetCode 22. Generate Parentheses 回溯 backtrack

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())", "()()()"]------------------------------Simple

2020-06-28 17:09:22 154

原创 LeetCode 402. Remove K Digits 栈

Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.Note:The length of num is less than 10002 and will be ≥ k. The given num does not contain any leading zero.Ex.

2020-06-28 15:46:39 163

原创 LeetCode 222. Count Complete Tree Nodes满二叉树节点个数

Given a complete binary tree, count the number of nodes.Note: Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as

2020-06-28 14:38:33 159

转载 IBM model1 推导

本文利用贝叶斯chain rule 对IBM model1模型进行了目标函数的推导与代码层面的一些实现,仅为学习时记录,理解不到位情况还请批评指正一.重要概念说明

2020-06-28 14:11:00 810

原创 偏差Bias和方差Variance的区别 不要只会画靶子图 P值

偏差 Bias偏差指的是由所有采样得到的大小为m的训练数据集训练出的所有模型的输出的平均值和真实模型输出之间的偏差。方差指的是由所有采样得到的大小为m的训练数据集训练出的所有模型的输出的方差。方差通常是由于模型的复杂度相对于训练样本数m过高导致的,比如一共有100个训练样本,而我们假设模型是阶数不大于200的多项式函数。由方差带来的误差通常体现在测试误差相对于训练误差的增量上。方差 VarianceBagging是Bootstrap Aggregate的简称,意思就是再抽样,即每一次从原始数据中根据

2020-06-28 11:18:43 450

原创 LeetCode 670. Maximum Swap 字符串有坑

Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get.Example 1:Input: 2736Output: 7236Explanation: Swap the number 2 and the number 7.Example 2:I

2020-06-27 17:19:26 162

原创 Adagrad求sqrt SGD Momentum Adagrad Adam AdamW RMSProp LAMB Lion 推导

随机梯度下降(Stochastic Gradient Descent)SGD经典的梯度下降法每次对模型参数更新时,需要遍历所有的训练数据。随机梯度下降法用单个训练样本的损失来近似平均损失。θt+1=θt−ηgt(公式1)\theta_{t+1} = \theta_{t}-\eta g_t (公式1)θt+1​=θt​−ηgt​(公式1)小批量梯度下降法(Mini-Batch Gradient Descent)把SGD中用单个训练样本改成用m个,实际中有这么几个问题:如何选取m:m一般是2的幂

2020-06-27 16:47:53 470

原创 LeetCode 777. Swap Adjacent in LR String 不能互穿 可达性

In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX" with "XR". Given the starting string start and the ending string end, return T

2020-06-26 16:37:21 181

原创 726. Number of Atoms FetchNum从字符串中Parse数

Given a chemical formula (given as a string), return the count of each atom.An atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name.1 or more digits representing the count of that element

2020-06-26 11:32:49 206

原创 LeetCode 316. Remove Duplicate Letters 栈顶

Given a string which contains only lowercase letters, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.Example 1:Input: "bcabc"

2020-06-26 10:22:37 166 1

原创 LeetCode 399. Evaluate Division 有向并查集(被指向的作根) 拓扑排序

Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0.Example:Given a / b = 2.0

2020-06-25 22:49:33 270

原创 LeetCode 465. Optimal Account Balancing 互相结账 回溯 组合

A group of friends went on holiday and sometimes lent each other money. For example, Alice paid for Bill's lunch for $10. Then later Chris gave Alice $5 for a taxi ride. We can model each transaction as a tuple (x, y, z) which means person x gave person y

2020-06-24 20:19:05 425

原创 LeetCode 1172. Dinner Plate Stacks 设计中间弹栈

You have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the samemaximumcapacity.Implement theDinnerPlatesclass:DinnerPlates(int capacity)Initializes the object with the maximumcapacityo...

2020-06-24 14:22:13 239

原创 LeetCode 843. Guess the Word 题有bug

This problem is aninteractive problemnew to the LeetCode platform.We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen as secret.You may call master.guess(word)to guess a word. The guessed word ...

2020-06-22 12:27:46 263

原创 LeetCode 299. Bulls and Cows 位置相同/不同的个数 遍历一趟

You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your sec

2020-06-19 13:23:53 144

原创 LeetCode 418. Sentence Screen Fitting TextView自适应

Given arows x colsscreen and a sentence represented by a list ofnon-emptywords, findhow many timesthe given sentence can be fitted on the screen.Note:A word cannot be split into two lines. The order of words in the sentence must remain unchanged...

2020-06-18 19:19:55 273

原创 LeetCode 444. Sequence Reconstruction Sequence不连续

Check whether the original sequenceorgcan be uniquely reconstructed from the sequences inseqs. Theorgsequence is a permutation of the integers from 1 to n, with 1 ≤ n ≤ 104. Reconstruction means building a shortest common supersequence of the sequence...

2020-06-18 15:35:20 268

原创 LeetCode 269. Alien Dictionary 拓扑排序

There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list ofnon-emptywords from the dictionary, wherewords are sorted lexicographically by the rules of this new language. Derive ...

2020-06-17 13:42:40 231

原创 LeetCode 311. Sparse Matrix Multiplication

Given twosparse matricesAandB, return the result ofAB.You may assume thatA's column number is equal toB's row number.Example:Input:A = [ [ 1, 0, 0], [-1, 0, 3]]B = [ [ 7, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 1 ]]Output: | 1 0...

2020-06-16 14:59:25 213

原创 Python zip 函数

zip的输入是positional auguments, 而且要求每个augument都是可以迭代的,例如list, tuple等。zip会把每个位置的元素拿出来拼成tuple,最后成为一个可以迭代每个tuple的对象。The single star * unpacks the sequence/collection into positional argumentszip 方法在 Python 2 和 Python 3 中的不同:在 Python 3.x 中为了减少内存,zip() 返回的是一个

2020-06-16 14:48:54 242

原创 LeetCode 1060. Missing Element in Sorted Array 二分

Given a sorted arrayAofuniquenumbers, find theK-thmissing number starting from the leftmost number of the array.Example 1:Input: A = [4,7,9,10], K = 1Output: 5Explanation: The first missing number is 5.Example 2:Input: A = [4,7,9,10]...

2020-06-16 11:22:54 390

原创 LeetCode 1088. Confusing Number II 回溯

We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. When 2, 3, 4, 5 and 7 are rotated 180 degrees, they become invalid.Aconfusing numberis a number that when rotate..

2020-06-15 09:56:07 1076

原创 LeetCode 642. Design Search Autocomplete System Trie树

Design a search autocomplete system for a search engine. Users may input a sentence (at least one word and end with a special character'#'). Foreach characterthey typeexcept '#', you need to return thetop 3historical hot sentences that have prefix th...

2020-06-14 10:57:15 202

原创 LeetCode 727. Minimum Window Subsequence 双指针 NextMatch数组

Given stringsSandT, find the minimum (contiguous)substringWofS, so thatTis asubsequenceofW.If there is no such window inSthat covers all characters inT, return the empty string"". If there are multiple such minimum-length windows, return ...

2020-06-13 21:04:26 310

原创 LeetCode 1153. String Transforms Into Another String 替换问题坑

Given two stringsstr1andstr2of the same length, determine whether you can transformstr1intostr2by doingzero or moreconversions.In one conversion you can convertalloccurrences of one character instr1toanyother lowercase English character....

2020-06-12 10:29:01 315

原创 LeetCode 1055. Shortest Way to Form String 字符串贪心 NextMatch数组

From any string, we can form asubsequenceof that string by deleting some number of characters (possibly no deletions).Given two stringssourceandtarget, return the minimum number of subsequences ofsourcesuch that their concatenation equalstarget. ...

2020-06-12 00:07:32 328

原创 LeetCode 489. Robot Room Cleaner 扫地机器人

Given a robot cleaner in a room modeled as a grid.Each cell in the grid can be empty or blocked.The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each turn it made is 90 degrees.When it tries to move into a blocked cell,

2020-06-09 23:19:22 349

原创 LeetCode 362. Design Hit Counter 桶

Design a hit counter which counts the number of hits received in the past 5 minutes.Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being made to the system in chronological order (ie, the timestamp

2020-06-09 16:40:37 206

原创 LeetCode 340. Longest Substring with At Most K Distinct Characters 双指针

Given a string, find the length of the longest substring T that contains at mostkdistinct characters.Example 1:Input: s = "eceba", k = 2Output: 3Explanation: T is "ece" which its length is 3.Example 2:Input: s = "aa", k = 1Output: 2Explanat..

2020-06-08 11:10:01 155

原创 LeetCode 249. Group Shifted Strings

Given a string, we can "shift" each of its letter to its successive letter, for example:"abc" -> "bcd". We can keep "shifting" which forms the sequence:"abc" -> "bcd" -> ... -> "xyz"Given a list of strings which contains only lowercase al.

2020-06-02 11:09:38 161

空空如也

空空如也

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

TA关注的人

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