- 博客(84)
- 资源 (5)
- 收藏
- 关注
原创 快手笔试题Leetcode165
比较两个版本号 version1 和 version2。如果 version1 > version2 返回 1,如果 version1 < version2 返回 -1, 除此之外返回 0。你可以假设版本字符串非空,并且只包含数字和 . 字符。. 字符不代表小数点,而是用于分隔数字序列。例如,2.5 不是“两个半”,也不是“差一半到三”,而是第二版中的第五个小版本。你可以假...
2019-08-25 19:13:56
538
原创 Leetcode101. Symmetric Tree
给定一个二叉树,检查它是否是镜像对称的。例如,二叉树 [1,2,2,3,4,4,3] 是对称的。1/ 2 2/ \ / 3 4 4 3但是下面这个 [1,2,2,null,3,null,3] 则不是镜像对称的:1/ 2 2\ 3 3说明:如果你可以运用递归和迭代两种方法解决这个问题,会很加分。来源:力扣(LeetCode)链接:https://...
2019-08-17 03:18:01
187
原创 Leetcode509. Fibonacci Number
斐波那契数,通常用 F(n) 表示,形成的序列称为斐波那契数列。该数列由 0 和 1 开始,后面的每一项数字都是前面两项数字的和。也就是:F(0) = 0, F(1) = 1 F(N) = F(N - 1) + F(N - 2), 其中 N > 1. 给定 N,计算F(N)。示例 1:输入:2 输出:1 解释:F(2) = F(1) + F(0) = 1 + 0 = 1. 示例...
2019-08-17 00:51:26
196
原创 Leetcode127. Word Ladder
给定两个单词(beginWord 和 endWord)和一个字典,找到从 beginWord 到 endWord的最短转换序列的长度。转换需遵循如下规则:每次转换只能改变一个字母。 转换过程中的中间单词必须是字典中的单词。 说明:如果不存在这样的转换序列,返回 0。 所有单词具有相同的长度。 所有单词只由小写字母组成。 字典中不存在重复的单词。 你可以假设beginWord 和 endW...
2019-08-15 04:13:24
170
原创 Leetcode451. Sort Characters By Frequency
给定一个字符串,请将字符串里的字符按照出现的频率降序排列。示例 1:输入: “tree”输出: “eert”解释: 'e’出现两次,'r’和’t’都只出现一次。 因此’e’必须出现在’r’和’t’之前。此外,"eetr"也是一个有效的答案。 示例2:输入: “cccaaa”输出: “cccaaa”解释: 'c’和’a’都出现三次。此外,"aaaccc"也是有效的答案。 注意"ca...
2019-08-13 02:05:45
165
原创 Leetcode75. Sort Colors
给定一个包含红色、白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。此题中,我们使用整数 0、 1 和 2 分别表示红色、白色和蓝色。注意: 不能使用代码库中的排序函数来解决这道题。示例:输入: [2,0,2,1,1,0] 输出: [0,0,1,1,2,2] 进阶:一个直观的解决方案是使用计数排序的两趟扫描算法。 首先,迭代...
2019-08-13 02:01:46
119
原创 Leetcode215. Kth Largest Element in an Array
在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。示例 1:输入: [3,2,1,5,6,4] 和 k = 2 输出: 5 示例 2:输入: [3,2,3,1,2,4,5,5,6] 和 k = 4 输出: 4 说明:你可以假设 k 总是有效的,且 1 ≤ k ≤ 数组的长度。来源:力扣(LeetCode)链接:...
2019-08-12 03:13:33
116
原创 Leetcode524. Longest Word in Dictionary through Deleting
给定一个字符串和一个字符串字典,找到字典里面最长的字符串,该字符串可以通过删除给定字符串的某些字符来得到。如果答案不止一个,返回长度最长且字典顺序最小的字符串。如果答案不存在,则返回空字符串。示例 1:输入: s = “abpcplea”, d = [“ale”,“apple”,“monkey”,“plea”]输出: “apple” 示例 2:输入: s = “abpcplea”, d...
2019-08-12 02:01:44
152
原创 Leetcode141. Linked List Cycle
给定一个链表,判断链表中是否有环。为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是-1,则在该链表中没有环。示例 1:输入:head = [3,2,0,-4], pos = 1 输出:true 解释:链表中有一个环,其尾部连接到第二个节点。 示例 2:输入:head = [1,2], pos = 0 输出:true ...
2019-08-12 00:52:16
105
原创 Leetcode88. Merge Sorted Array
给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组。说明:初始化 nums1 和 nums2 的元素数量分别为 m 和 n。 你可以假设 nums1 有足够的空间(空间大小大于或等于 m +n)来保存 nums2 中的元素。 示例:输入: nums1 = [1,2,3,0,0,0], m = 3 nums2 = [2...
2019-08-12 00:28:56
100
原创 Leetcode680. Valid Palindrome II
Given a non-empty string s, you may delete at most one character.Judge whether you can make it a palindrome.Example 1: Input: “aba” Output: True Example 2: Input: “abca” Output:True Explanation: Y...
2019-08-11 02:31:26
112
原创 Leetcode345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only thevowels of a string.Example 1:Input: “hello” Output: “holle” Example 2:Input: “leetcode” Output: “leotcede” Note: The vowels does ...
2019-08-11 01:28:51
193
原创 Leetcode633. Sum of Square Numbers
Given a non-negative integer c, your task is to decide whetherthere’re two integers a and b such that a2 + b2 = c.Example 1:Input: 5 Output: True Explanation: 1 * 1 + 2 * 2 = 5Example 2:Input: 3...
2019-08-11 01:11:43
120
原创 Leetcode167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order,find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers ...
2019-08-11 00:45:52
102
原创 Leetcode494. Target Sum
You are given a list of non-negative integers, a1, a2, …, an, and atarget, S. Now you have 2 symbols + and -. For each integer, youshould choose one from + and - as its new symbol.Find out how man...
2019-08-05 23:46:29
118
原创 Leetcode647. Palindromic Substrings
Given a string, your task is to count how many palindromic substringsin this string.The substrings with different start indexes or end indexes are countedas different substrings even they consist ...
2019-08-05 21:22:38
92
原创 Leetcode338. Counting Bits
Given a non negative integer number num. For every numbers i in therange 0 ≤ i ≤ num calculate the number of 1’s in their binaryrepresentation and return them as an array.Example 1:Input: 2 Outpu...
2019-08-05 20:28:37
107
原创 Leetcode322. Coin Change
You are given coins of different denominations and a total amount ofmoney amount. Write a function to compute the fewest number of coinsthat you need to make up that amount. If that amount of money...
2019-08-05 19:47:38
110
原创 Leetcode309. Best Time to Buy and Sell Stock with Cooldown
Say you have an array for which the ith element is the price of agiven stock on day i.Design an algorithm to find the maximum profit. You may complete asmany transactions as you like (ie, buy one ...
2019-08-05 17:47:19
107
原创 Leetcode300. Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longestincreasing subsequence.Example:Input: [10,9,2,5,3,7,101,18] Output: 4 Explanation: The longestincreasing subsequence is [2,3,7,101]...
2019-08-05 16:40:54
107
原创 Leetcode279. Perfect Squares
Given a positive integer n, find the least number of perfect squarenumbers (for example, 1, 4, 9, 16, …) which sum to n.Example 1:Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4. Example 2:I...
2019-08-05 15:31:11
87
原创 Leetcode221. Maximal Square
Given a 2D binary matrix filled with 0’s and 1’s, find the largestsquare containing only 1’s and return its area.Example:Input:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0Output: 4动态规划20msclass ...
2019-08-04 19:17:56
112
原创 Leetcode198. House Robber
You are a professional robber planning to rob houses along a street.Each house has a certain amount of money stashed, the only constraintstopping you from robbing each of them is that adjacent hous...
2019-08-04 18:10:16
103
原创 Leetcode152. Maximum Product Subarray
Given an integer array nums, find the contiguous subarray within anarray (containing at least one number) which has the largest product.Example 1:Input: [2,3,-2,4] Output: 6 Explanation: [2,3] has...
2019-08-04 17:34:27
103
原创 Leetcode139. Word Break
Given a non-empty string s and a dictionary wordDict containing a listof non-empty words, determine if s can be segmented into aspace-separated sequence of one or more dictionary words.Note:The s...
2019-08-04 16:09:39
80
原创 Leetcod91. Decode Ways
A message containing letters from A-Z is being encoded to numbersusing the following mapping:‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given a non-empty string containingonly digits, determine the to...
2019-07-31 17:38:54
102
原创 Leetcode121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of agiven stock on day i.If you were only permitted to complete at most one transaction (i.e.,buy one and sell one share of the stock),...
2019-07-31 14:12:59
88
原创 Leetcode96. Unique Binary Search Trees
Given n, how many structurally unique BST’s (binary search trees) thatstore values 1 … n?Example:Input: 3 Output: 5 Explanation: Given n = 3, there are a total of 5unique BST’s:1 3 3...
2019-07-31 13:11:40
80
原创 Leetcode70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct wayscan you climb to the top?Note: Given n will be a positive ...
2019-07-30 21:54:00
82
原创 Leetcode92. Reverse Linked List II
Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4 Output: 1->4->3->2->5->...
2019-07-30 21:33:35
92
原创 Leetcode206. Reverse Linked List
Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Follow up:A linked list can be reversed either iteratively or recursively....
2019-07-30 19:44:17
85
原创 Leetcode64. Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path fromtop left to bottom right which minimizes the sum of all numbers alongits path.Note: You can only move either down or right at a...
2019-07-30 16:48:41
76
原创 Leetcode63. Unique Paths II
A robot is located at the top-left corner of a m x n grid (marked‘Start’ in the diagram below).The robot can only move either down or right at any point in time. Therobot is trying to reach the bo...
2019-07-30 16:43:14
79
原创 Leetcode 62. Unique Paths
A robot is located at the top-left corner of a m x n grid (marked‘Start’ in the diagram below).The robot can only move either down or right at any point in time. Therobot is trying to reach the bo...
2019-07-29 22:18:16
86
原创 Leetcode53 Maximum Subarray
Given an integer array nums, find the contiguous subarray (containingat least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation...
2019-07-29 20:50:44
139
原创 C++ memset初始化为0/-1
1、对于字符数组,可以将其初始化为任意一个字符2、对int数组只能初始化0和-1memset(dp, 1, len*sizeof(dp));无法初始化
2019-07-29 16:46:59
1195
原创 Leetcode 5. 最长回文子串
给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。示例 1:输入: “babad” 输出: “bab” 注意: “aba” 也是一个有效答案。 示例 2:输入: “cbbd” 输出: “bb”来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/longest-palindromic-substrin...
2019-07-28 14:39:55
98
转载 [转]Leetcode刷题指南和top100题目
https://blog.youkuaiyun.com/lingpy/article/details/88085446
2019-07-26 20:52:06
316
转载 C++关键字
注:上表中为C++98/03中的63个关键字,其中红色标注为C语言中的32个关键字。C++11中有73个关键字,新增加的10个为:alignas、alignof、char16_t、char32_t、constexpr、decltype、noexpect、nullptr、static_assert、thread_local以下是对部分关键字的解释:1、asm_asm是一个语句的分隔符。不能单独...
2019-07-25 19:27:52
151
转载 [转]C语言运算符优先级 快速记忆
初等单目一二级, // 初等运算符和单目运算符分别是第1、2优先级乘除求余加减移, // 这句里面的运算符全归为算术运算符,移表示移位关系等于不等于, // 关系运算符(< <= > >=)按位与来异或或, // 位运算符优先级顺序: & -> ^ -> |逻辑与或条件弱, // 逻辑运算符优先级顺序: && -> |...
2019-07-24 19:33:16
135
Visual Assist X 2018.rar
2019-05-27
Runge_Kutta法解初值问题
2018-01-11
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人