LeetCode-202009
77. Combinations-20200908
Given two integers n and k, return all possible combinations of k numbers out of 1 … n.
You may return the answer in any order.
Example 1:
Input: n = 4, k = 2
Output:
[
[2,4],
[3,4],
[2,3],
[1,2],
[1,3],
[1,4],
]
Example 2:
Input: n = 1, k = 1
Output: [[1]]
Constraints:
1 <= n <= 20
1 <= k <= n
首先想着用循环做… 刚开始刷题都没什么思想,想了想行不通,实际上这道题应该用回溯来做,第一个算法是看题解做的(TwT脑子还没转过来),第二个用的是离散树章的前缀码,数据结构中也有讲到,选择或者不选择,就可以组合出不重复的前缀码。
1234567891011121314151617181920212223242526272829 ...
SwiftUI-ContentShape
What I encountered.
Recently when I’m testing Tap Gesture, but however I’ve got in some trouble. And touch event doesn’t work.
However, after find some answers on stackoverflow. I noticed that Color.clear’s contentShape is zero, which means it is untouchable.
And the solution is to add modifier .contentShape(Rectangle()) before .onTapGesture modifier.
Here’s my test code. You can comment or uncommnet the contentShape modifier to see what happened.
123456789101112131415161718192021222324252627282 ...
Swift-GCD
Introduction
When we use network requesting, always use escaping closure to resolve the data passed from net to our UI, though it generally works, but when getting into some intricate cases, we need to use nested clousure, which is not elegant, so study Threading Control Tech is useful for us to code better.
For example, we need to request a Image from internet, we can request data in the background, and allow UI moves quickly in the main thread, after fetched data, refresh the Image Control in ...
每日一练之"DASCTF 2020 6th Wp"
T0p_Gear
首先ida进去看到就5个函数,看了看字符串发现了UPX字样,所以先用upx -d 解压,解压后看到main函数
看来是三次Check,并且每次都会调用401080这个子函数,进去发现是一个字符串比较,诶,莫非传的是明文,直接在每个call sub_401080 打断点
分别是 404dba、4064f5、404fbf
chk2弄了半天rax没数据发现是txt文件没放,TwT
之后再看chk2,是对文件读取并做aes加密,但是动调直接绕过了,如果有反调试的话,这位师傅分析的AES其实不错http://www.mamicode.com/info-detail-3047406.html
Python多线程编程
多线程操作在涉及网络编程常常用到,学习一下。本文使用threading库
常用函数
12345678910import threadingprint(threading.current_thread())print(threading.active_count())print(threading.main_thread().name)#<_MainThread(MainThread, started 4514921920)>#1#MainThread
创建线程
123456789101112131415161718192021222324252627282930import threadingimport timedef thread_body(): t = threading.current_thread() for i in range(3): print("线程{0}运行第{1}次".format(t.name, i)) time.sleep(1) print("线程" + t.nam ...
天翼杯-Re-Wp
Mobile
就做了一道简单mobile题
关键函数在so里面,ida打开
主要函数如下
后来想了想是矩阵乘法,正好学深度学习看了看numpy,那就用用吧
12345678# x xx两个数组 xArr = np.array(xArr) xxArr = np.array(xxArr) xxArr = np.resize(xxArr, (32, 32)) xxArr_inv = np.linalg.inv(xxArr.T) # 转置再求逆solve = np.dot(xArr, xxArr_inv)print(solve)
结果得到FAKE{th15_15_n07_7h3_r341_f14g!}
看了看init_array,果然换表了
对于换表操作,似曾相识(去年Xman入营选拔赛)
发现AB0是进栈了寄存器后做了些验证,于是可以从跳转到的AC8位置创建函数,但是不好看代码啊,那就动调,然后得到数据
12xArr=[ 230633, 241616, 235681, 243044, 215926, 247340, 226354, 208221 ...
Swift-利用Mirror创建结构体字典(JSON)
1234567891011121314151617181920212223242526272829303132333435363738struct MyStruct: Codable { let id: String let regionsID: Int? let created: Int let modified: Int let removed: Int? enum CodingKeys: String, CodingKey, CaseIterable { case id = "id" case regionsID = "regions_id" case created = "created" case modified = "modified" case removed = "removed" } var jsonDictionary: ...
Python数据库操作
主要是利用pymysql库来进行操作
样例数据库字段如下
数据库连接
123456def get_database(): return pymysql.connect(host='localhost', user='root', password='***', database='***', charset='utf8')
这里连接的是本地的root用户
C 增加
1234567891011121314151617181920def db_insert(name): connection = get_database() try: # 创建游标 with connection.cursor() as cursor: sql = 'insert into user (userid, name) values (%s, %s)' max_id = db_max_userid() ...
UIKit-DateFormatter
转载自:https://www.jianshu.com/p/2aa894e12080
Thursday, Mar 17, 2016
12345let dateFormate = DateFormatter()dateFormate.dateFormat = "EEEE, MMM d, yyyy"let date = Date()let stringOfDate = dateFormate.string(from: date)print(stringOfDate)
03/17/2016
12345let dateFormate = DateFormatter()dateFormate.dateFormat = "MM/dd/yyyy"let date = Date()let stringOfDate = dateFormate.string(from: date)print(stringOfDate)
03-17-2016 07:10
12345let dateFormate = DateFormatter()dateFormate.d ...
UIKit-Eureka 自定义Row
本文链接
准备
我们需要定义一个UserInfoRow
类型需要遵守Equatable协议
12345678910struct User: Equatable { var name: String var email: String var dateOfBirth: Date var pictureUrl: URL?}func ==(lhs: User, rhs: User) -> Bool { return lhs.name == rhs.name}
定义Cell
因为Eureka里Row里其实是一个继承自UITableViewCell的Cell,先要定义Cell
所有Cell需要用final标记并且遵从CellType协议
123456789101112131415161718192021222324252627282930final class UserInfoCell: Cell<User>, CellType { var userImageView = UIImag ...