Skip to content

Instantly share code, notes, and snippets.

# Source : http://www.geeksforgeeks.org/maximum-product-subarray/
def maxProd(input):
prod = temp_prod = 1
i=0
negativeCount = 1
start_SubArray = -1
end_SubArray = -1
while i < len(input) :
@pratikone
pratikone / fb_hackercup2016_boomerang.py
Last active January 30, 2016 05:38
Solution for Facebook hacker cup 2016 Boomerang question https://www.facebook.com/hackercup/problem/910374079035613/
from datetime import datetime
def reading_input(file, teja):
with open(file) as w:
content = w.readlines()
ctr = 0
boomerangs = []
nights = content[0] #ignoring this value as we can print without nights
@pratikone
pratikone / bfs2way.py
Last active August 29, 2015 14:08
BFS - 2 way search code
import rubik
import unittest
def shortest_path(start, end):
"""
Using 2-way BFS, finds the shortest path from start_position to
end_position. Returns a list of moves.
You can use the rubik.quarter_twists move set.
Each move can be applied using rubik.perm_apply
"""
@pratikone
pratikone / temp.c
Created December 15, 2013 18:38
tep
//
// main.c
// MultiplyX
//
// Created by Pratik Anand on 02/12/13.
// Copyright (c) 2013 Pratik Anand. All rights reserved.
//
#include <stdio.h>
@pratikone
pratikone / MultiplyMilion-File.c
Created December 11, 2013 09:43
Multiply 2 million-digit numbers using files I/O
//
// simple.c
// MultiplyX
//
// Created by Pratik Anand on 02/12/13.
// Copyright (c) 2013 Pratik Anand. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
@pratikone
pratikone / MultiplyMillion-Memory.c
Created December 11, 2013 09:41
C code to multiply 2 million-digit numbers
//
// main.c
// MultiplyX
//
// Created by Pratik Anand on 02/12/13.
// Copyright (c) 2013 Pratik Anand. All rights reserved.
//
#include <stdio.h>