使用了long。没有解决int的溢出问题。 class Solution { public: int divide(int dividend, int divisor) { //if (dividend == 0) return 0; //if (divisor == 1) return divid ...
分类:
其他好文 时间:
2020-05-31 18:17:56
阅读次数:
101
链表(Linked list)是一种常见的基础数据结构,是一种线性表,但是并不会按线性的顺序存储数据,而是在每一个节点里存到下一个节点的指针(Pointer)。——维基百科 链表 如果将链表简单抽象成图片,大概长这样。 是不是跟链子很像?(好吧,不是很像)但是你细品,应该还是能发现链表跟你认识的某位 ...
分类:
其他好文 时间:
2020-05-31 18:13:58
阅读次数:
158
Manhattan Wiring 题意: There is a rectangular area containing n × m cells. Two cells are marked with “2”, and another two with “3”. Some cells are occup ...
分类:
其他好文 时间:
2020-05-31 16:26:04
阅读次数:
66
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. Example: Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], ...
分类:
其他好文 时间:
2020-05-31 13:17:49
阅读次数:
57
LeetCode的第一题,英文单词书中 Abandon 一般的存在,让我们来看一下题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. ...
分类:
编程语言 时间:
2020-05-31 11:10:15
阅读次数:
107
不断更新值和进位。 class Solution { public: int getSum(int a, int b) { return b == 0 ? a : getSum(a ^ b, ((unsigned int)a & b) << 1); } }; ...
分类:
其他好文 时间:
2020-05-30 01:24:53
阅读次数:
70
进阶解法1:排序双指针 class Solution { public: vector<int> intersect(vector<int>& nums1, vector<int>& nums2) { sort(nums1.begin(), nums1.end()); sort(nums2.begi ...
分类:
编程语言 时间:
2020-05-30 01:20:17
阅读次数:
70
删除链表中倒数第n个结点 题目:LeetCode19 Given a linked list, remove the n-th node from the end of list and return its head. Example: Given linked list: 1->2->3->4- ...
分类:
其他好文 时间:
2020-05-29 09:26:32
阅读次数:
50
题目描述 leetcode - 2:https://leetcode-cn.com/problems/add-two-numbers/ 解题关键 C++ 链表 数据结构的定义和遍历 代码 /** * Definition for singly-linked list. * struct ListNo ...
分类:
其他好文 时间:
2020-05-29 09:15:52
阅读次数:
73
1、CSS3自定义鼠标样式 最近想要使用自定义鼠标样式,看了cursor的样式不好看,就想到cursor属性能不能自定义图片,翻看了下CSS3文档,发现是可以的 格式为:cursor:url('图片url'),备选样式; body{ cursor: url('a.ico'),pointer; } 注 ...
分类:
其他好文 时间:
2020-05-28 13:25:15
阅读次数:
107