UCAS自动同步课件脚本

Cool Idea

在UCAS进入研一的生活接近两个礼拜,发现老师的课件基本上都上传到课程网站,然后是一节一节给的。这样,每次老师更新课件的时候,我们都得开一下网页,然后看看是不是更新了?(虽然有邮箱提醒,但是这种邮件我都直接忽略的),于是萌生了写个脚本来自动下载的想法。

Continue reading


leetcode Mini Parser

leetcode 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 or other lists.

Note: You may assume that the string is well-formed:

  • String is non-empty.
  • String does not contain white spaces.
  • String contains only digits 0-9, [, ,, ].

Example 1:

Example 2:

Continue reading


leetcode Shuffle an Array

leetcode Shuffle an Array

Shuffle a set of numbers without duplicates.

Example:

Continue reading


leetcode Ransom Note

leetcode 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 
from 
the 
magazines ; 
otherwise, 
it 
will 
return 
false.

Each 
letter
 in
 the
 magazine 
string 
can
 only 
be
 used 
once
 in
 your 
ransom
 note.

Note:
You may assume that both strings contain only lowercase letters.

Continue reading


leetcode Linked List Random Node

leetcode 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 list is extremely large and its length is unknown to you? Could you solve this efficiently without using extra space?

Example:

Continue reading


leetcode Insert Delete GetRandom O(1) – Duplicates allowed

leetcode Insert Delete GetRandom O(1) – Duplicates allowed

Design a data structure that supports all following operations in average O(1) time.

Note: Duplicate elements are allowed.

  1. insert(val): Inserts an item val to the collection.
  2. remove(val): Removes an item val from the collection if present.
  3. getRandom: Returns a random element from current collection of elements. The probability of each element being returned is linearly related to the number of same value the collection contains.

Example:

Continue reading