Skip to content

Instantly share code, notes, and snippets.

View karimfikry's full-sized avatar

Kareem Elshahawy karimfikry

  • Amazon Web Services
  • Berlin, Germany
View GitHub Profile
@karimfikry
karimfikry / leetcode-bloomberg.md
Created February 24, 2018 00:42 — forked from jayant91089/leetcode-bloomberg.md
Answers to leetcode questions tagged 'Bloomberg'

121 Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.

If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.

Example 1: Input: [7, 1, 5, 3, 6, 4] Output: 5

/*
This example shows how you can use your data structure as a basis for
your Firebase security rules to implement role-based security. We store
each user by their Twitter uid, and use the following simplistic approach
for user roles:
0 - GUEST
10 - USER
20 - MODERATOR
function get_vimeo_id (url) {
var vimeo_regex = /https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/;
var match = url.match(vimeo_regex);
return match ? match[3] : undefined;
};