Skip to content

Instantly share code, notes, and snippets.

View sarb1208's full-sized avatar

Sarabjyot Singh sarb1208

View GitHub Profile
@sarb1208
sarb1208 / martian.c
Created July 15, 2018 12:07
C-code for spoj problem named Martian Mining
#include<stdio.h>
int Y[500][500];
int B[500][500];
int max(int a,int b){
if(a>b)
return a;
return b;
}
@sarb1208
sarb1208 / mfish.cpp
Last active July 20, 2018 17:22
Code for spoj problem named "Cath Fish"
#include<bits/stdc++.h>
using namespace std;
int f[100001],s[100001];
int I[100001];
int memo[100001];
int fun(int i,int n){
int ans = 0;
if(i>n)
return 0;
if(memo[i]!=-1)
@sarb1208
sarb1208 / loop.c
Created August 1, 2018 19:09
Following is C code snippet for detecting a cycle in a singly linked list
/*The structure of linked list is the following
struct node
{
int data;
node* next;
};*/
int detectloop(struct node *list){
// your code goes here
if(list==0)
return 0;
@sarb1208
sarb1208 / RevList.cpp
Created August 4, 2018 15:55
Following is reursive way of reversing a singly linked list.
/* Linked List Node structure
struct Node {
int data;
Node *next;
}
*/
// Should reverse list and return new head.
Node* fun(Node* head,Node* prev){
if(head==0)