问题描述 给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。 你的算法时间复杂度必须是 O(log n) 级别。 如果数组中不存在目标值,返回 [-1, -1]。 示例 1: 输入: nums = [5,7,7,8,8,10], tar ...
分类:
编程语言 时间:
2020-09-17 21:50:55
阅读次数:
30
每天 3 分钟,走上算法的逆袭之路。 前文合集 每日一道 LeetCode 前文合集 代码仓库 GitHub: https://github.com/meteor1993/LeetCode Gitee: https://gitee.com/inwsy/LeetCode 题目:翻转二进制数 题目来源: ...
分类:
其他好文 时间:
2020-09-17 21:35:31
阅读次数:
34
dfs暴力,也就是二进制枚举的思想,也就是枚举所有的情况,这个题目有个很好的剪枝,就是先排序,然后在 这样可以避免答案出现相同的组合。 code: class Solution { public: int p[1000]; vector<vector<int>> ans; vector<int> v ...
分类:
其他好文 时间:
2020-09-17 21:24:53
阅读次数:
42
typedef struct{ int val; int index; }st; int cmp(const void* a, const void* b){ return ((st*)a)->val - ((st*)b)->val; } int* arrayRankTransform(int* a ...
分类:
编程语言 时间:
2020-09-17 20:52:31
阅读次数:
33
这道题很简单,只需要从头开始遍历两个链表,每次将两个链表的当前元素比较,值较小的结点就存入到新的链表 需要注意的是加入新表是l3,旧表是l1,l2,那么将旧的表结点插入新的表的时候需要如下方式 l3.Next=l1 l3=l3.Next 而不能是 l3=l1 l3=l3.Next 这两种方式的区别是 ...
分类:
其他好文 时间:
2020-09-17 20:44:34
阅读次数:
30
用两个栈实现一个队列。队列的声明如下,请实现它的两个函数appendTail和deleteHead,分别完成在队列尾部插入整数和在队列头部删除整数的功能。(若队列中没有元素,deleteHead操作返回-1)来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof著作权归领
分类:
其他好文 时间:
2020-09-17 20:32:56
阅读次数:
28
使用队列实现栈的下列操作:push(x)--元素x入栈pop()--移除栈顶元素top()--获取栈顶元素empty()--返回栈是否为空注意:你只能使用队列的基本操作--也就是pushtoback,peek/popfromfront,size,和isempty这些操作是合法的。你所使用的语言也许不支持队列。你可以使用list或者deque(双端队列)来模拟一个队列,只要是标准的队列操作即可。你可
分类:
其他好文 时间:
2020-09-17 20:32:25
阅读次数:
29
Problem LeetCode Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where t ...
分类:
编程语言 时间:
2020-09-17 20:29:16
阅读次数:
30
char * reformatDate(char * date){ int len = strlen(date); int i,j=0; char* str = (char*)calloc(len*2,sizeof(char)); char* arr[] = {"Jan","01","Feb","0 ...
分类:
其他好文 时间:
2020-09-17 20:28:40
阅读次数:
42
struct ListNode* removeElements(struct ListNode* head, int val){ if (head == NULL) { return NULL; } head->next = removeElements(head->next, val); retu ...
分类:
其他好文 时间:
2020-09-17 19:25:01
阅读次数:
24