Skip to content

Instantly share code, notes, and snippets.

View sreeprasad's full-sized avatar

Sreeprasad sreeprasad

  • BlackRock
  • New York
View GitHub Profile
@sreeprasad
sreeprasad / count number of bits set fast approach
Created June 28, 2018 14:12
Find the number of bits set in O(K) where K is the number of bits set
int findCount(int N) {
while(N>0){
count++;
N= N&(N-1);
}
return count;
}
@sreeprasad
sreeprasad / slow count number of bits set
Last active June 28, 2018 14:11
Find number of bits set with O(N) time where N is the total number of bits in the number
int findBitSet(int n){
int count=0;
while(n>0){
if(n&1 == 0) {
count++;
}
n=>>1;
}
return count;
}
@sreeprasad
sreeprasad / isOdd
Last active June 28, 2018 14:02
check if number is odd
if (a&1 == 1) then a is odd
if (a&1 == 0) then a is even
@sreeprasad
sreeprasad / interview-questions.md
Created June 13, 2018 15:21 — forked from jvns/interview-questions.md
A list of questions you could ask while interviewing

A lot of these are outright stolen from Edward O'Campo-Gooding's list of questions. I really like his list.

I'm having some trouble paring this down to a manageable list of questions -- I realistically want to know all of these things before starting to work at a company, but it's a lot to ask all at once. My current game plan is to pick 6 before an interview and ask those.

I'd love comments and suggestions about any of these.

I've found questions like "do you have smart people? Can I learn a lot at your company?" to be basically totally useless -- everybody will say "yeah, definitely!" and it's hard to learn anything from them. So I'm trying to make all of these questions pretty concrete -- if a team doesn't have an issue tracker, they don't have an issue tracker.

I'm also mostly not asking about principles, but the way things are -- not "do you think code review is important?", but "Does all code get reviewed?".

// to encrypt
openssl enc -aes-256-cbc -e -in ~/location/of/file/to/encrypt -out ~/location/to/put/encrypted/file
// to decrypt
openssl enc -aes-256-cbc -e -in ~/location/of/file/to/decrypt -out ~/location/to/put/decrypted/file
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int N,count=0;
scanf(" %d",&N);
int* array = new int[N];
@sreeprasad
sreeprasad / MaxArea.cpp
Last active March 21, 2018 03:58
Container with most water area
class Solution {
public:
int maxArea(vector<int>& height) {
int N = height.size();
int maxArea=0;
int left=0, right=N-1;
while (left<right) {
maxArea = max(maxArea, (min(height[left], height[right]) * (right-left)) );
if (height[left] < height[right]) left++;
else right--;
@sreeprasad
sreeprasad / best saving rate
Created February 3, 2018 20:09
MIT: Introduction to Computer Science and Programming in Python : problem set 2 problem c
original_salary = float(input("Enter annual salary "))
house_cost_in_millions = int(input("Enter House cost in millions "))
house_cost = house_cost_in_millions * 1000000
down_payment = 0.25*house_cost
semi_annual_raise = 0.07
annual_investment_return = 0.04
delta = 101
low = 0
high = 1000
package com.sreeprasad.algorithms;
import java.util.Stack;
public class RecommendedSequence {
private static StringBuilder recommended(String S) {
StringBuilder result = new StringBuilder();