- 博客(7)
- 收藏
- 关注
原创 大数相加 c++
大数相加c++用string的方式处理大数相加,最后对所得字符串作逆转处理。#include <iostream>#include <algorithm>using namespace std;int main(){ string str1, str2; cin >> str1; cin >> str2; string output; int carry = 0; int i = str1.size() - 1, j = str2
2021-08-02 11:42:11
131
原创 有序数组中某个数字的出现次数
有序数组中某个数字的出现次数c++二分查找 特殊情况处理#include <iostream>#include <vector>using namespace std;int main(){ int target; cin >> target; vector<int> input = {2, 2};// int s;// while (cin >> s) {// input.push_back(s);// }
2021-08-02 11:29:04
152
原创 力扣215
class Solution {public: int findKthLargest(vector<int>& nums, int k) { int l = 0, r = nums.size() - 1, target = nums.size() - k; while (l < r) { int mid = fastSelect(nums, l, r); if (mid == target)
2021-04-21 21:50:34
159
原创 leetcode 540. 有序数组中的单一元素 c++解法
leetcode 540. 有序数组中的单一元素 (中等)给定一个只包含整数的有序数组,每个元素都会出现两次,唯有一个数只会出现一次,找出这个数。示例 1:输入: [1,1,2,3,3,4,4,8,8]输出: 2方法1:由于数组是有序的,而且要找的数只有一个,那么该数肯定在偶数位,长度为1的数组单独解决class Solution {public: int singleNonDuplicate(vector<int>& nums) { int l
2021-04-19 20:28:21
253
原创 反转字符串中的单词 III
力扣485. 最大连续 1 的个数给定一个二进制数组, 计算其中最大连续 1 的个数。class Solution {public: int findMaxConsecutiveOnes(vector<int>& nums) { int j = 0; int len = nums.size(); if (len == 0) { return 0; } vector<
2021-03-27 15:21:21
66
原创 python return和print的一些笔记
python return和printreturn:函数的返回值,在直接调用该函数时是不输出的,只有在打印时才能看到其返回值def add(x, y): return x + yadd(4, 5)无输出def add(x, y): return x + yprint(add(4, 5))输出:9print:打印一个值def add(x, y): print x + y...
2020-04-05 21:14:39
228
1
原创 opencv2.4.13库文件
release库文件:opencv_calib3d2413.libopencv_contrib2413.libopencv_core2413.libopencv_features2d2413.libopencv_flann2413.libopencv_gpu2413.libopencv_highgui2413.libopencv_imgproc2413.libopencv_leg...
2019-03-19 09:39:48
358
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅