![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
====算法与数据结构====
team79
我在努力。
展开
-
LeetCode 282. Expression Add Operators
题目Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value.Exampl原创 2017-02-07 18:42:24 · 295 阅读 · 0 评论 -
LeetCode 164. Maximum Gap
题目Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 if the array contains less than 2 elements.You ma原创 2017-02-05 12:45:44 · 244 阅读 · 0 评论 -
LeetCode 99. Recover Binary Search Tree
题目Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note: A solution using O(n) space is pretty straight forward. Could you devise a con原创 2017-02-05 11:52:14 · 374 阅读 · 0 评论 -
LeetCode 327. Count of Range Sum
题目Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive. Range sum S(i, j) is defined as the sum of the elements in nums between indices i and j (i ≤ j), in原创 2017-02-05 11:20:46 · 454 阅读 · 0 评论 -
LeetCode 25. Reverse Nodes in k-Group
给一个链表,每k个反转一下,最后不够的不反转。 写了半天,实在是太弱了。 struct XNode{ ListNode *t1, *t2; int flag; };class Solution { public: XNode dfs( ListNode* pre, ListNode* nows, int cnt, int k ){ //if( nows =原创 2017-02-04 14:32:04 · 269 阅读 · 0 评论 -
Leetcode 330. Patching Array
解法真的厉害!学习了!这道题给我们一个有序的正数数组nums,又给了我们一个正整数n,问我们最少需要给nums加几个数字,使其能组成[1,n]之间的所有数字,注意数组中的元素不能重复使用。我们定义一个变量miss,用来表示[0,n]之间最小的不能表示的值,那么初始化为1。那么此时我们能表示的范围是[0, miss),表示此时我们能表示0到miss-1的数,如果此时的num <= miss,那么我们可原创 2017-02-03 21:53:16 · 509 阅读 · 0 评论 -
LeetCode 316. 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 order原创 2017-02-07 19:26:19 · 290 阅读 · 0 评论 -
[Offer收割]编程练习赛8
1473 : 小Ho的强迫症题解在mod L的情况下每次加D,最终相邻点的距离一定为__gcd(L,D),然后只需要判断是否大于脚长F即可#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <vector> #include <map> #include <queue> usin原创 2017-03-05 17:24:15 · 339 阅读 · 0 评论 -
[Offer收割]编程练习赛10
题目1 : 出勤记录I略。题目2 : 出勤记录II题解:dp【i】【0】表示最后一个是O的前i个可能的种类数 dp【i】【1】表示最后一个是L并且连续1次的前i个可能的种类数 dp【i】【2】表示最后一个是L并且连续2次的前i个可能的种类数 因为还要考虑没去的情况 那么最终答案就是 sum =E( ( sum + ans[i-1] * ans[N-i] % MOD ) % MOD; )代原创 2017-03-19 15:27:27 · 478 阅读 · 0 评论