jadvpetc

导航

2020年1月30日 #

Leetcode总结帖【11-20】

摘要: 11. Container with Most Water 使用双指针i和j,分别指向数组的两端。每次最大值是res = max(res, (j - i) * min(height[j], height[i]))。每次根据比较height[i]和height[j]的大小来更新i和j。 只有下一个he 阅读全文

posted @ 2020-01-30 22:31 jadvpetc 阅读(158) 评论(0) 推荐(0) 编辑

Leetcode总结帖【1-10】

摘要: 1. Two sum 因为只有一个solution(pair),所以一旦发现解返回即可。使用unordered_map或者unordered_set存当前数字,找complement. 2. Add two number 双指针,使用dummy作为返回链表。 3. Longest substring 阅读全文

posted @ 2020-01-30 06:47 jadvpetc 阅读(137) 评论(0) 推荐(0) 编辑

2020年1月22日 #

Graph题目总结【不定期更新】

摘要: Find minimal ops to convert one str to another Description Given two alphabet strings str1 and str2. You can change the characters in str1 to any alph 阅读全文

posted @ 2020-01-22 12:00 jadvpetc 阅读(226) 评论(0) 推荐(0) 编辑

2020年1月10日 #

计算器相关题目总结

摘要: 选自leetcode basic calculator Version 1: Support [ + - ] (not tested) class Solution { public int calculate(String s) { int len = s.length(), sign = 1, 阅读全文

posted @ 2020-01-10 20:29 jadvpetc 阅读(449) 评论(0) 推荐(0) 编辑

2020年1月1日 #

归并排序和快速排序模版

摘要: 摘自Acwing 归并排序 1 #include <iostream> 2 using namespace std; 3 4 const int N = 1e5 + 10; 5 6 int n; 7 int q[N], tmp[N]; 8 void merge_sort(int q[], int l 阅读全文

posted @ 2020-01-01 10:55 jadvpetc 阅读(178) 评论(0) 推荐(0) 编辑

2019年12月4日 #

[Leetcode] Sliding Window Summary

摘要: Template from https://leetcode.com/problems/minimum-window-substring/discuss/26808/Here-is-a-10-line-template-that-can-solve-most-'substring'-problems 阅读全文

posted @ 2019-12-04 23:29 jadvpetc 阅读(252) 评论(0) 推荐(0) 编辑

2019年11月25日 #

[Leetcode] 21 & 23 & 56 & 57: Intervals

摘要: Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the fi 阅读全文

posted @ 2019-11-25 10:24 jadvpetc 阅读(158) 评论(0) 推荐(0) 编辑

2019年11月23日 #

[Leetcode] 787 Cheapest Flights Within K Stops

摘要: 原题链接 There are n cities connected by m flights. Each fight starts from city u and arrives at v with a price w. Now given all the cities and flights, t 阅读全文

posted @ 2019-11-23 05:52 jadvpetc 阅读(238) 评论(0) 推荐(0) 编辑

2019年11月22日 #

[Leetcode] 322 & 518. Coin Change 1 & 2

摘要: Coin Change 1 You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coin 阅读全文

posted @ 2019-11-22 00:04 jadvpetc 阅读(139) 评论(0) 推荐(0) 编辑