原创 [leetcode]單鏈表類題目總結(應用雙指針)

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNo

原创 [leetcode]排列類問題

31. Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater p

原创 [leetcode]求和類問題

Two sum i Given an array of integers, return indices of the two numbers such that they add up to a specific target

原创 one-shot iteration

python學習手冊514頁 def myzip(*args): iters = map(iter, args) while iters: res = [next(i) for i in iters

原创 gdb and C memory layout

A simple C program: #include <stdlib.h> int main() { int i; for (i = 0; i < 10; ++i) printf("Hello_

原创 C++ virtual table

Best reference explaining virtual table and dynamic binding 1.

原创 [leetcode]Implement strStr()

28. Implement strStr() Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 i

原创 [leetcode]Longest Common Prefix

14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. 我

原创 [leetcode]Container With Most Water

11. Container With Most Water Given n non-negative integers a1, a2, …, an, where each represents a point at coordi

原创 [leetcode]Median of Two Sorted Arrays

4. Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the

原创 stack overflow[part1]

C program: #include <stdio.h> #include <stdlib.h> #include <string.h> int check_authentication(char *password) {

原创 [leetcode]Jump Game II

45. Jump Game II Given an array of non-negative integers, you are initially positioned at the first index of the ar

原创 [leetcode]Search for a Range

34. Search for a Range Given an array of integers sorted in ascending order, find the starting and ending position

原创 python: learn yield and send[part 1]

Sample code def gen(): for i in range(3): x = yield i print(x) >>> g = gen() >>

原创 Leetcode string題目中的雙指針模板

leetcode中有不少求最長或者最短滿足特定條件子串的長度,這些題目都有共性:使用雙指針,且使用哈希表記錄字符出現的次數。有高人總結的模板,配合一下總結的該類問題食用更加! Template: int findSubstrin