Skip to content

Instantly share code, notes, and snippets.

/*
num[i] > num[j], i < j, find max j-i
example:
[3 4 5 1 3]
i j
*/
#include <vector>
#include <string>
# Steps To follow to download your leetcode:
#1. Login to leetcode account on your default browser
#2. Get your session Id for leetcode.com from Browser ( for chrome: press F12, Go to Resources, Go to Cookies and copy value of field 'PHPSESSID'; you can find similar value for firefox and other browsers).
#3. Create a folder to save your leetcode codes.
#4. Keep the downloaded leetcode.py into that folder
#5. Replace PHPSESSID field in leetcode.py file with your session ID (copied in step 2)
#6. run file as 'python leetcode.py
#7. wait for all submssions to download.
# Features:
$ git rm -r --cached .
$ git add .
$ git commit -m "Clean up ignored files"
@mengdiwang
mengdiwang / regex.py
Last active April 25, 2018 05:56
regex.py
# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r'<a target="_blank" title="(.*?)" href="(.*?)">(.*?)</a>'
test_str = "<p>  二〇一八年四月二十日<br><br><a target=\"_blank\" title=\"上海证券交易所股票上市规则(2018年4月修订)\" href=\"/aboutus/mediacenter/hotandd/a/20180420/4a6cd527bc7bcac21dd66a2abb60d3d5.doc\">上海证券交易所股票上市规则(2018年4月修订)<br></a><a target=\"_blank\" title=\"《上海证券交易所股票上市规则(2018年4月修订)》修订说明\" href=\"/aboutus/mediacenter/hotandd/a/20180420/f086a86397ee054f984443a8ac9d1f3a.doc\">《上海证券交易所股票上市规则(2018年4月修订)》修订说明</a><br><br type=\"_moz\">&nbsp;</p>"
matches = re.finditer(regex, test_str, re.MULTILINE | re.UNICODE)