自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(35)
  • 收藏
  • 关注

原创 牛客-合并两个排序的链表

牛客-合并两个排序的链表初始化一个新的节点第一个链表的节点p值与第二个链表的节点q值进行比较,第一个节点小,则p后移,否则q后移直到某个链表遍历完,然后接上剩余未遍历完的链表因为新节点newHead的next才开始赋值的,所以返回的是newHead.next/*struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};*/class Solution

2020-06-02 22:46:33 137

原创 牛客-链表中倒数第k个节点

牛客-链表中倒数第k个节点思路1:设链表的长度为len倒数第k个就是正数第len-k+1个/*struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};*/ListNode* FindKthToTail(ListNode* pListHead, unsigned int k) { if (pListHead==NULL) {

2020-06-01 23:11:00 163

原创 Leecode 24. 两两交换链表中的节点

Leecode 24. 两两交换链表中的节点struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; class Solution {public: ListNode* swapPairs(ListNode* head) { if (head == NULL || head -> next == NULL) {

2020-06-01 21:25:14 140

原创 牛客-二进制中1的个数

牛客-二进制中1的个数#include <stdio.h>#include <queue>#include <stack>#include <math.h>#include <map>#include <string.h>#include <string>#include <cstring>#include <set>#include <algorithm>#incl

2020-05-24 20:39:17 137

原创 牛客-矩形覆盖

牛客-矩形覆盖#include <stdio.h>#include <queue>#include <stack>#include <math.h>#include <map>#include <string.h>#include <string>#include <cstring>#include <set>#include <algorithm>#include

2020-05-24 19:44:35 113

原创 牛客-变态跳台阶

牛客-变态跳台阶2^(n-1)次方#include <stdio.h>#include <queue>#include <stack>#include <math.h>#include <map>#include <string.h>#include <string>#include <cstring>#include <set>#include <algorithm&gt

2020-05-24 19:34:31 100

原创 牛客-跳台阶

牛客-跳台阶#include <stdio.h>#include <queue>#include <stack>#include <math.h>#include <map>#include <string.h>#include <string>#include <cstring>#include <set>#include <algorithm>#include &

2020-05-24 18:45:38 109

原创 牛客-旋转数组的最小值

牛客-旋转数组的最小值#include <stdio.h>#include <queue>#include <stack>#include <math.h>#include <map>#include <string.h>#include <string>#include <cstring>#include <set>#include <algorithm>#incl

2020-05-24 18:27:25 101

原创 牛客-用两个栈实现队列

牛客-用两个栈实现队列#include <stdio.h>#include <queue>#include <stack>#include <math.h>#include <map>#include <string.h>#include <string>#include <cstring>#include <set>#include <algorithm>#incl

2020-05-24 18:05:19 114

原创 牛客-重建二叉树

牛客-重建二叉树#include <stdio.h>#include <queue>#include <stack>#include <math.h>#include <map>#include <string.h>#include <string>#include <cstring>#include <set>using namespace std; struct Tre

2020-05-18 21:54:50 144

原创 牛客-从尾到头打印链表

牛客-从尾到头打印链表#include <stdio.h>#include <queue>#include <stack>#include <math.h>#include <map>#include <string.h>#include <string>#include <cstring>#include <set>using namespace std;struct Li

2020-05-18 20:46:59 90

原创 牛客-替换空格

牛客-替换空格if (str == NULL || length < 0) { return; } int originLen = 0; int blankNum = 0; for (int i=0; str[i]!='\0'; i++) { originLen++; if (str[i]==' ') { blankNum++;

2020-05-18 20:03:03 104

原创 牛客-二维数组中的查找

牛客-二维数组中的查找class Solution {public: bool Find(int target, vector<vector<int> > array) { if (array.empty()) { return false; } int col = array[0].size(); int row = array.size(); for (int i=

2020-05-18 19:26:55 121

原创 牛客-反转链表

牛客-反转链表/*struct ListNode { int val; struct ListNode *next; ListNode(int x) : val(x), next(NULL) { }};*/class Solution {public: ListNode* ReverseList(ListNode* pHead) { if (pHead == NULL) return NULL; ListNode *cur, *p=NULL,

2020-05-18 11:38:24 85

原创 牛客-二叉树层序遍历

牛客-二叉树层序遍历#include <stdio.h>#include <queue>#include <stack>#include <math.h>#include <map>#include <string.h>#include <string>#include <set>using namespace std;struct TreeNode { int val;

2020-05-18 11:36:39 140

原创 iOS xib中设置cell的自动计算行高

xib中cell的自动计算行高xib中设置xib中固定部分的空间,高度一定要是固定值(就算label可以根据字体计算出行号,为避免xib中红色错误提示,也给label设置固定值),通常只有红色Label部分是变化的高度,如果要所有文字全部显示,那么label的numberOfLines设置为0(我这个图设置的是最多只显示5行)使用// 1. 初始化tableViewtableView.rowHeight = UITableViewAutomaticDimensiontableView.esti

2020-05-10 12:38:16 474

原创 Swift 中.self和 type(of:)

代码基于:swift 4.0在一个类中,可以通过 customClass.self 取出不带命名空间的类名。print(self) // <testOne.ViewController: 0x1033094f0>print(self.description) // <testOne.ViewController: 0x101d10350>print(ViewController.self) // ViewControllerpo type(of: self) //

2020-05-10 12:36:01 767

原创 带导航栏的控制器里包含tableView时自动下移和不下移的问题

备忘:记得检查以下代码// 下面这个很重要。edgesForExtendedLayout =[] // 默认时all(all的话是navigation的top开始布局。[] 为空。 空的话是从导航栏下开始布局)tableView是否需要自动调整Insetif #available(iOS 11.0, *) { extendedLayoutIncludesOpaqueBars = true; tableView.contentInsetAdjustmentBehavior = .n

2020-05-10 12:29:14 204 1

原创 CoreText 学习记录

代码基于Swift 4.0.####一、坐标系CoreText 的原点是左下角。 而进行UI布局时参照的坐标系原点在左上角。所以一般会对坐标系进行翻转。在override func draw(_ rect: CGRect) 中调用// coreText 设置前10个字为红色带下划线 func test01() { // 1. let context = UIGraphicsGetCurrentContext() // 2.

2020-05-10 12:17:38 99

原创 UITableView显示数据

代码基于Swift4.0用tableView很简单的显示数据,主要是熟悉API代码:import UIKitclass ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let tableView = UITableView(frame: view.bounds, style: .plain) table

2020-05-10 11:40:52 153

原创 UIWebView的使用

实现5个功能1 在屏幕中显示指定的网页2 控制屏幕中的网页3 在网页中加载显示PDF,Word,和JPEG图片4 在网页中加载HTML代码5 在网页中实现触摸处理(加载html文件)git代码地址:https://github.com/shine93/WebViewGuide...

2020-05-10 11:02:46 101

原创 UIBezierPath贝塞尔弧线

下面两个网页是我学习时发现的相关的知识网页,总结了常用的知识点。以免忘记,特记录在此。UIBezierPath贝塞尔弧线常用方法iOS UIBezierPath类介绍几点需要注意:绘制的图形要写在drawRect函数里面,在View里面绘制图形。下面是我熟悉UIBezierPath而写的几个小例子。放在这吧,以后再完善补充。//// XXCycleView.m// XXGraphics//// Created by shine on 2016/12/22.// Copyright

2020-05-10 10:57:26 149

原创 汇率换算项目总结

汇率换算问题集合afn有时候请求接口会有问题接口没错Attempting to modify object outside of a write transaction - call beginWriteTransaction on an RLMRealm instance first.(企图在 写入事务 外修改对象)[http://blog.csdn.net/qq_31810357/article/details/52088268];修改UITableView 右侧索引栏的背景颜色和字体

2020-05-10 10:51:44 458

原创 初识React之组件

移动端跨平台开发,从零开始学习React Native。第一个demo:打印Hello React一、 知识点需要将react的框架导入到项目中,注意browser.min.js也要导入type=“text/babel”ReactDOM.render是React的最基本方法用于将模板转为HTML语言,并插入指定的DOM节点。ReactDOM.render(template,targetDOM),该方法接收两个参数:第一个是创建的模板,多个dom元素外层需使用一个标签进行包裹,如<div&g

2020-05-10 10:17:00 84

原创 Python简单实例URL

URL拼接参数import requestspayload = {'key1': 'value1', 'key2': 'value2'}r2 = requests.get("http://httpbin.org/get", params=payload)print(r2.url) //http://httpbin.org/get?key1=value1&key2=value2URL响应内容import requestsr = requests.get('https://api.g

2020-05-10 10:02:51 168

原创 修改数组中的某个model的值

注意Swift的数组是结构体。用for model in array 修改model的方法行不通应该直接对数组的值进行操作。参考下面:func handlePicModel() { guard let _ = truckPostModel.pics else { return } for i in 0..<truckPostModel.pics!.count { truckPostModel.pics![i].smallUrl = tr.

2020-05-10 09:53:34 1688

原创 iOS URL拼接参数

代码Swift 5.0问题前导:代码拼接参数和后台约定好下发的链接是这种格式:http://www.xxx.com?。 后来过一段时间后台同学忘记了,下发成了不带问号的格式http://www.xxx.com。 导致后面拼接参数后链接错误。以免以后下发本身就带参数的链接https://w ww.xx.com?distinct_id=421268 又要完蛋,还是严谨点吧extension ...

2020-04-30 18:31:28 2200

原创 LeetCode240. 搜索二维矩阵 II (面试题4:二维数组中的查找)

思路:从每排的最后一个数开始和目标值进行比较,大于target则排除此列,小于target则排除此行。一步一步缩小比较范围。Swift通过代码:func findNumberIn2DArray(_ matrix: [[Int]], _ target: Int) -> Bool { if matrix.count <= 0 { retu...

2020-04-30 18:14:02 90

原创 2017春招百度编程题——买帽子

1 [编程题] 买帽子时间限制:1秒空间限制:32768K度度熊想去商场买一顶帽子,商场里有N顶帽子,有些帽子的价格可能相同。度度熊想买一顶价格第三便宜的帽子,问第三便宜的帽子价格是多少?输入描述:首先输入一个正整数N(N <= 50),接下来输入N个数表示每顶帽子的价格(价格均是正整数,且小于等于1000)输出描述:如果存在第三便宜的帽子,请输出这个价格是多少,否则输出-1...

2020-04-30 18:11:38 145

原创 Leetcode3. 无重复字符的最长子串

思路:首先减少循环次数,避免超时Swift通过代码:func lengthOfLongestSubstring(_ s: String) -> Int { var maxLong = 0 var setString = Set<Character>() var startIndex = 0 let ss =...

2020-04-30 18:07:23 87

原创 Leetcode2. 两数相加

Swift 通过代码:public class ListNode { public var val: Int public var next: ListNode? public init(_ val: Int) { self.val = val self.next = nil }}class Solution { fu...

2020-04-30 18:05:43 96

原创 Leetcode1. 两数之和

思路: 用一个临时数组存储未匹配的数,如果存在匹配,则数组中一定存在(target - num)的值。Swift 通过代码:class Solution { func twoSum(_ nums: [Int], _ target: Int) -> [Int] { var numsArray = [Int]() var end = 0 ...

2020-04-30 18:03:47 72

原创 NYOJ289

苹果时间限制:3000 ms | 内存限制:65535 KB 难度:3描述ctest有n个苹果,要将它放入容量为v的背包。给出第i个苹果的大小和价钱,求出能放入背包的苹果的总价钱最大值。输入有多组测试数据,每组测试数据第一行为2个正整数,分别代表苹果的个数n和背包的容量v,n、v同时为0时结束测试,此时不输出。接下来的n行,每行2个正整数,用空格隔开,分别代表苹果的大小c和价钱w。所有输入数字

2017-10-03 13:45:41 222

原创 NYOJ201

作业题时间限制:3000 ms | 内存限制:65535 KB 难度:3描述小白同学这学期有一门课程叫做《数值计算方法》,这是一门有效使用数字计算机求数学问题近似解的方法与过程,以及由相关理论构成的学科……今天他们的Teacher S,给他们出了一道作业题。Teacher S给了他们很多的点,让他们利用拉格朗日插值公式,计算出某严格单调函数的曲线。现在小白抄下了这些点,但是问题出现了,由于我们

2017-10-03 12:36:35 176

原创 1000

#include using namespace std;int main(){ int a,b; cin>>a >>b; couta+b endl; return 0;}

2016-11-17 09:59:31 214

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除