[44]Wildcard Matching [45]Jump Game II (2018年11月28日,算法群衍生题) 题目背景和 55 一样的,问我能到达最后一个index的话,最少走几步. 题解: [55]Jump Game (2018年11月27日,算法群) 给了一个数组nums,nums[i] = k 代表站在第 i 个位置的情况下, 我最多能往前走 k 个单位.问我能不能到达最后一个 index. 题解:虽然是贪心分类,我还是用dp解了.dp[i] 代表我能不能到达第 i 个位置. c…
The recursive program will result in TLE like this: class Solution { public: bool isMatch(const char *s, const char *p) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. if…
1. Array 基础 27 Remove Element 26 Remove Duplicates from Sorted Array 80 Remove Duplicates from Sorted Array II 277 Find the Celebrity 189 Rotate Array 41 First Missing Positive 299 Bulls and Cows 134 Gas Station 118 Pascal's Triangle 很少考 119 Pascal's…
Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. For example: A =…
[334]Increasing Triplet Subsequence (2019年2月14日,google tag)(greedy) 给了一个数组 nums,判断是否有三个数字组成子序列,使得子序列递增.题目要求time complexity: O(N),space complexity: O(1) Return true if there exists i, j, k such that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < k …
目录 这是一个对LeetCode题目归类的索引,分类标准参考了July大神的<编程之法>以及LeetCode的tag项.分类可能还不太合理,逐步完善,请见谅~ 题主本人也在一点一点的刷题,这个目录跟着刷的题每天更新~ Hope you enjoy coding! 数组 Array 寻找和为定值的两个数 1.Two Sum 167.Two Sum II 从数组移除元素 26.Remove Duplicates from Sorted Array 27.Remove Element 283.Mov…
算法面试过程中,题目类型多,数量大.大家都不可避免的会在LeetCode上进行训练.但问题是,题目杂,而且已经超过1300道题. 全部刷完且掌握,不是一件容易的事情.那我们应该怎么办呢?找规律,总结才是制胜法宝. 下面我们就来看看 Grokking the Coding Interview: Patterns for Coding Questions 的分类及每个类型的经典题目: 1. Pattern: Sliding window,滑动窗口类型 经典题目: Maximum Sum Subar…
If you understand the comments below, never will you make mistakes with binary search! thanks to A simple CPP solution with lower_bound and C++ O(logn) Binary Search that handles duplicate, thanks to phu1ku 's answer on the second post. http://en.cpp…
for the backtracking part, thanks to the video of stanford cs106b lecture 10 by Julie Zelenski for the nice explanation of recursion and backtracking, highly recommended. in hdu 2553 cout N-Queens solutions problem, dfs is used. // please ignore, bel…
huffman coding, greedy algorithm. std::priority_queue, std::partition, when i use the three commented lines, excution time increase to 15ms from 0ms, due to worse locality? thanks to http://acm.hdu.edu.cn/discuss/problem/post/reply.php?action=support…
https://leetcode.com/problems/remove-duplicate-letters/ Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical o…
Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, whit…
All LeetCode Questions List 题目汇总 Sorted by frequency of problems that appear in real interviews. Last updated: October 2, 2017Google (214)534 Design TinyURL388 Longest Absolute File Path683 K Empty Slots340 Longest Substring with At Most K Distinct C…