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 re | |
from re import sub | |
import time | |
import cookielib | |
from cookielib import CookieJar | |
import urllib2 | |
from urllib2 import urlopen | |
import difflib | |
cj = CookieJar() | |
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) |
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 re | |
from re import sub | |
import time | |
import cookielib | |
from cookielib import CookieJar | |
import urllib2 | |
from urllib2 import urlopen | |
import difflib | |
cj = CookieJar() | |
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) |
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 sqlite | |
import time | |
import datetime | |
conn = sqlite3.connect('tutorial.db') | |
c = conn.cursor() | |
sql = "SELECT * FROM plotting WHERE keyword = ?" | |
wordUsed ='Python Sentiment' | |
def readData(): |
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 singleNumber(int[] nums) { | |
int ones = 0 ; //The bits that have appeared 1st time or 4th time or 7th time ... etc [We have to return this value] | |
int twos = 0 ; // The bits that have appeared 2nd time or 5th time or 8th time .. etc. | |
int not_threes ; //‘ones’ and ‘twos’ contain those extra bits which appear 3rd time. Removethem by finding out common set bits in ‘ones’ and ‘twos’. | |
for( int x : nums ) | |
{ | |
twos |= ones & x ; //add it to twos if it exists in ones | |
ones ^= x ; //if it exists in ones, remove it, otherwise, add it |
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
// Unique Binary Search Trees [LEETCODE][JUNE CHALLANGE] | |
//Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? | |
//Example: | |
//Input: 3 | |
//Output: 5 | |
//Explanation: | |
//Given n = 3, there are a total of 5 unique BST's: |
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
// You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. | |
// Given n, find the total number of full staircase rows that can be formed. | |
// n is a non-negative integer and fits within the range of a 32-bit signed integer. | |
public class Solution { | |
public int arrangeCoins(int n) { | |
int level = 1; | |
for (long sum = 0; sum <= n; level++) { | |
sum += level; | |
} |
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
// You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. | |
// Given n, find the total number of full staircase rows that can be formed. | |
// n is a non-negative integer and fits within the range of a 32-bit signed integer. | |
// Example 1: | |
// n = 5 |
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
// Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). | |
// For example: | |
// Given binary tree [3,9,20,null,null,15,7], | |
// 3 | |
// / \ | |
// 9 20 | |
// / \ | |
// 15 7 | |
// return its bottom-up level order traversal as: |
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
// Prison Cells After N Days | |
// Solution | |
// There are 8 prison cells in a row, and each cell is either occupied or vacant. | |
// Each day, whether the cell is occupied or vacant changes according to the following rules: | |
// If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied. | |
// Otherwise, it becomes vacant. | |
// (Note that because the prison is a row, the first and the last cells in the row can't have two adjacent neighbors.) |
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
// Prison Cells After N Days | |
// Solution | |
// There are 8 prison cells in a row, and each cell is either occupied or vacant. | |
// Each day, whether the cell is occupied or vacant changes according to the following rules: | |
// If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied. | |
// Otherwise, it becomes vacant. | |
// (Note that because the prison is a row, the first and the last cells in the row can't have two adjacent neighbors.) |
OlderNewer