- .pem .ppk 差别 - November 11, 2020
什么是PEM文件
PEM(Private Enhanced Mail)是一个Base64编码的文本文件,包含了:
private key,
CA server certificate
trust chain additonal certificates (root certificate, intermediate certificate)
下面是一个例子:
# Pri...
- Single Linked List Reverse - May 25, 2017
Single Linked List Reverse
Linked List Reverse is a typical interview question to determine whether the interviewee understand linked-list data structure good enought or not.
Here are two typical...
- Int + Unsigned Int - May 17, 2017
Int + Unsigned Int
Let’s see some example code first.
Example 1
int main()
{
unsigned int X = 10;
int Y = 0;
if( X > Y ) cout << "X > Y" << endl;
else cout << "X ...
- Leetcode - 523. Continuous Subarray Sum - May 12, 2017
523. Continuous Subarray Sum
Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the mu...
- Leetcode - 416. Partition Equal Subset Sum - October 09, 2016
416. Partition Equal Subset Sum
Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is eq...
- Leetcode - 417. Pacific Atlantic Water Flow - October 09, 2016
417. Pacific Atlantic Water Flow
Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the “Pacific ocean” touches the left and top edges of the ...
- Leetcode - 355. Design Twitter - October 01, 2016
355. Design Twitter
Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most recent tweets in the user’s news feed. Your desi...
- Leetcode - 133. Clone Graph - October 01, 2016
133. Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
OJ’s undirected graph serialization:
Nodes are labeled uniquely.
We use # as a se...
- Leetcode - 399. Evaluate Division - September 29, 2016
399. Evaluate Division
Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return t...
- Leetcode - 390. Elimination Game - September 29, 2016
390. Elimination Game
There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you reach the end of the list.
Re...
- Leetcode - 273. Integer to English Words - September 26, 2016
273. Integer to English Words
Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 2^31 - 1.
For example,
123 -> "One Hundred Twenty T...
- Leetcode - 404. Sum of Left Leaves - September 23, 2016
404. Sum of Left Leaves
Find the sum of all left leaves in a given binary tree.
Example:
3
/ \
9 20
/ \
15 7
There are two left leaves in the binary tree, with values 9 and 15 res...
- Leetcode - 405. Convert a Number to Hexadecimal - September 23, 2016
405. Convert a Number to Hexadecimal
Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used.
Note:
All letters in hexadecimal...
- Leetcode - 400. Nth Digit - September 23, 2016
400. Nth Digit
Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, …
Note:
n is positive and will fit within the range of a 32-bit signed integer (n < 2^31)....
- Leetcode - 401. Binary Watch - September 22, 2016
401. Binary Watch
A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).
Each LED represents a zero or one, with the lea...
- Leetcode - 402. Remove K Digits - September 18, 2016
402. Remove K Digits
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible.
Note:
The length of num is less ...
- Leetcode - 398. Random Pick Index - September 13, 2016
398. Random Pick Index
Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array....
- Leetcode - 396. Rotate Function - September 12, 2016
396. Rotate Function
Given an array of integers A and let n to be its length.
Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a “rotation function” F o...
- Leetcode - 397. Integer Replacement - September 12, 2016
397. Integer Replacement
Given a positive integer n and you can do operations as follow:
If n is even, replace n with n/2.
If n is odd, you can replace n with either n + 1 or n - 1.
What is the m...
- Leetcode - 394. Decode String - September 06, 2016
394. Decode String
Given an encoded string, return it’s decoded string.
The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k ti...
- Leetcode - 393. UTF-8 Validation - September 06, 2016
393. UTF-8 Validation
A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules:
For 1-byte character, the first bit is a 0, followed by its unicode code.
For n-byt...
- Leetcode - 395. Longest Substring with At Least K Repeating Characters - September 06, 2016
395. Longest Substring with At Least K Repeating Characters
Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears...
- Leetcode - 392. Is Subsequence - September 06, 2016
392. Is Subsequence
Given a string s and a string t, check if s is subsequence of t.
You may assume that there is only lower case English letters in both s and t. t is potentially a very long (le...
- Leetcode - 354. Russian Doll Envelopes - September 04, 2016
354. Russian Doll Envelopes
You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and height of...
- Leetcode - 167. Two Sum II - Input array is sorted - September 02, 2016
167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.
The function twoS...
- Leetcode - 377. Combination Sum IV - September 01, 2016
377. Combination Sum IV
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.
Example:
nums = [1,...
- Leetcode - 389. Find the Difference - August 28, 2016
389. Find the Difference
Given two strings s and t which consist of only lowercase letters.
String t is generated by random shuffling string s and then add one more letter at a random position.
...
- Leetcode - 386. Lexicographical Numbers - August 27, 2016
386. Lexicographical Numbers
Given an integer n, return 1 - n in lexicographical order.
For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].
Please optimize your algorithm to use less...
- Leetcode - 381. Insert Delete GetRandom O(1) - August 27, 2016
380. Insert Delete GetRandom O(1)
Design a data structure that supports all following operations in average O(1) time.
Note: Duplicate elements are allowed.
insert(val): Inserts an item val to t...
- Leetcode - 380. Insert Delete GetRandom O(1) - August 27, 2016
380. Insert Delete GetRandom O(1)
Design a data structure that supports all following operations in average O(1) time.
insert(val): Inserts an item val to the set if not already present.
remove(v...
- Leetcode - 388. Longest Absolute File Path - August 23, 2016
388. Longest Absolute File Path
Suppose we abstract our file system by a string in the following manner:
The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents:
dir
subdir1
subd...
- Leetcode - 385. Mini Parser - August 22, 2016
385. Mini Parser
Given a nested list of integers represented as a string, implement a parser to deserialize it.
Each element is either an integer, or a list – whose elements may also be integers ...
- Leetcode - 382. Linked List Random Node - August 21, 2016
382. Linked List Random Node
Given a singly linked list, return a random node’s value from the linked list. Each node must have the same probability of being chosen.
Follow up:
What if the linked...
- Leetcode - 383. Ransom Note - August 19, 2016
383. Ransom Note
Given an arbitrary ransom
note string and
another
string
containing letters from all
the
magazines, write a function
that
will
return
true
if
the
ransom
note
can
be
constructed fr...
- Leetcode - 25. Reverse Nodes in k-Group - August 14, 2016
25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in...
- Leetcode - 206. Reverse Linked List - August 14, 2016
206. Reverse Linked List
Reverse a singly linked list.
1. Analyse
First, we give a diagram of a linked list.
Node0---->Node1---->Node2...
If we want to reverse the pointer of Node1, wh...
- Leetcode - 376. Wiggle Subsequence - July 23, 2016
376. Wiggle Subsequence
A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if o...
- Leetcode - 300. Longest Increasing Subsequence - July 17, 2016
300. Longest Increasing Subsequence
Given an unsorted array of integers, find the length of longest increasing subsequence.
For example,
Given [10, 9, 2, 5, 3, 7, 101, 18],
The longest increasi...
- Leetcode - 367. Valid Perfect Square - July 09, 2016
367. Valid Perfect Square
Given a positive integer num, write a function which returns True if num is a perfect square else False.
Note: Do not use any built-in library function such as sqrt.
Ex...
- Leetcode - 368. Largest Divisible Subset - July 09, 2016
368. Largest Divisible Subset
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.
If...
- Leetcode - 373.Find K Pairs with Smallest Sums - July 09, 2016
373. Find K Pairs with Smallest Sums
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.
Define a pair (u,v) which consists of one element from the first ...
- Leetcode - 372. Super Pow - July 07, 2016
372. Super Pow
Your task is to calculate a^b mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.
Example1:
a = 2
b = [3]
Result: 8...
- Setup PPTP VPN on Ubuntu Vultr VPS - June 05, 2016
Setup PPTP VPN on Ubuntu Vultr VPS
If you are reading this artical, I’m assuming you have purchased a Vultr VPS and setup a Ubuntu Server. If you need to setup a VPN, you may probably a Chinese :)...
- - November 27, 2015