This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "static void main" must be defined in a public class. | |
public class Main { | |
public static void main(String[] args) { | |
int[] arr = {1,2,3,5,10,20,35,100}; | |
int left = 0, right = arr.length - 1; | |
int target = 4; | |
while (left <= right) { | |
int mid = left + (right - left) / 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
public int[] twoSum(int[] nums, int target) { | |
// 1. initialize HashMap for {Number -> Index} | |
Map<Integer, Integer> map = new HashMap<>(); | |
// 2. iterate the array | |
for (int i = 0; i < nums.length; i ++) { | |
// 3. check if such 'num2' exists in the hashmap | |
int num2 = target - nums[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import csv | |
import matplotlib.pyplot as plt | |
from plot_data import plot_data | |
def plot_data(data): | |
""" simple plot for x, y """ | |
plt.title('BLE Plot'); | |
# plt.plot([row[0] for row in data], label="x") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you come from bash you might have to change your $PATH. | |
export PATH=$PATH:$HOME/bin:/usr/local/bin:~/.composer/vendor/bin:/usr/local/apache-maven/apache-maven-3.3.9/bin:/anaconda/bin | |
export PATH="$HOME/.rbenv/bin:$PATH" | |
export PATH="$PATH:$HOME/.rvm/bin" | |
eval "$(rbenv init -)" | |
# Path to your oh-my-zsh installation. | |
export ZSH=/Users/sangyunpark/.oh-my-zsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def read_csv(filename, num_rows): | |
# print("") | |
df = pd.read_csv(filename, encoding='latin-1', nrows=num_rows) | |
table = df[['Name', 'Country']] | |
search_terms = [] | |
# getting columns of name and country |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import selenium.webdriver as webdriver | |
from time import sleep | |
def get_results(search_term): | |
MAX_LINKS = 2 # Set the maximum number of links to gather | |
# Use google to search the search term | |
url = "https://www.google.com" | |
browser = webdriver.Chrome() | |
browser.get(url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import re | |
def extract_email_from_url(url): | |
''' | |
From the provided url, it extracts all valid email addresses | |
:param url: URL to enter | |
:return: Set of email addresses in string | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |