Skip to content

Instantly share code, notes, and snippets.

View rohit-nsit08's full-sized avatar

rohit jangid rohit-nsit08

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rohit-nsit08
rohit-nsit08 / FoxAndMp3.java
Created April 16, 2013 10:44
topcoder : SRM 571 Div 1 Problem :250
/*
* @author rohit jangid
* @data Apr 16, 2013
* @file-name FoxAndMp3.java
* @license this code is licensed under WTFPL V-2.0
* @details Topcoder SRM 571 Div I problem 250
*/
import java.util.Arrays;
fuel = map(lambda x:int(x), raw_input().split())
distance = map(lambda x:int(x), raw_input().split())
# takes the standard input as space separated integers in two lines.
diff = [b-a for b,a in zip(fuel, distance)] # creates the diff array
diff = diff + diff # to account for cyclic array
start = 0 # let say we start from 0 the position
end = 0
@rohit-nsit08
rohit-nsit08 / kmp.c
Created February 26, 2013 03:29
c implementation of knuth-morris-pratt algorithm for exact string matching.
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#define P_SIZE 7
int F[P_SIZE] ;
void prefix(char* p, int m) {
int i = 1, j = 0;
@rohit-nsit08
rohit-nsit08 / triplets.c
Created February 26, 2013 03:15
c implementation of triplets problem on interview street [ first attempt , not at all optimized ]
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
struct node {
int data;
int frequency;
struct node* left;
struct node* right;
@rohit-nsit08
rohit-nsit08 / androidMenu.java
Created December 9, 2012 10:32
main activity file for creating list view
package com.app.my;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.app.Activity;
import android.app.ListActivity;
@rohit-nsit08
rohit-nsit08 / androidLayoutMenu.xml
Created December 9, 2012 10:30
andoid list layout file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
@rohit-nsit08
rohit-nsit08 / parantheses.c
Created September 2, 2011 20:54
pattern generation
#include<stdio.h>
int n;
void print(char *pattern,int index,int open,int close);
int main()
{
printf("enter the number of parantheses");
scanf("%d",&n);
@rohit-nsit08
rohit-nsit08 / quick.c
Created September 2, 2011 18:34
quick sort
//quick sort
#include<stdio.h>
void quicksort(int*arr,int left, int right);
int partition(int *arr,int left,int right);
int main()
{
int arr[6]={5,4,1,2,8,3};
int i;
@rohit-nsit08
rohit-nsit08 / selection.c
Created September 2, 2011 16:50
simple selection sort
//selection sort
#include<stdio.h>
int main()
{
int arr[5]={5,4,3,2,1};
int i,j,smallest,t;
int n = sizeof(arr)/sizeof(int);
for(i=0;i<n-1;i++)
{