Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
//#include <alloc.h>
int main(void){
printf("Check the ram usage and press any to start the process");
getchar();
int c=0;
void *v=NULL;
v=malloc(1);
void (* va[33000]);
printf("Reached till array with size %d\n",sizeof(va));
@codegagan
codegagan / ProblemB.java
Created May 17, 2014 09:00
Some problem
//Enter the input as commandline arguments
public class Problem_B{
public static void main(String args[]){
//System.out.println("Positive Sum");
//if(args[0]=='')System.out.println("Please Enter Commandline Arguments");
if(args[0].charAt(0)=='-')System.out.println("Enter Positive No. of Test Cases");
int Test_Cases=Integer.parseInt(args[0].substring(0,1));
//System.out.println(args[0].substring(0,1));
int T[]=new int[Test_Cases];
if(args[0].charAt(1)=='-' || args[0].charAt(2)=='-')System.out.println("Enter Positive count of numbers in 1st Test Case");
@codegagan
codegagan / semExport.sql
Last active August 29, 2015 14:05
Oracle DB export of Shared Expense Management
--------------------------------------------------------
-- File created - Tuesday-August-19-2014
--------------------------------------------------------
--------------------------------------------------------
-- DDL for Table EXPENSE
--------------------------------------------------------
CREATE TABLE "EXPENSE"
( "ID" NUMBER,
"AMOUNT" NUMBER,
@codegagan
codegagan / lvalue.c
Created September 10, 2015 18:15
lvalue concept test
#include<stdio.h>
int main()
{
int a = 10, b,x=0;
a >=5 ? b=100:b= 200;
printf("%d\n", b);
return 0;
}
@codegagan
codegagan / TestClass.java
Created March 27, 2016 14:35
Shootout challenge, some geometry helpful classes
/**
* Created by gagan on 27/3/16.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class TestClass {
public static void main(String args[]) throws Exception {
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
/**
* Created by gagan on 2/4/16.
*/
public class Tour {
/**
* Created by gagan on 2/4/16.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
public class Criminal {
@codegagan
codegagan / amazonProblems.txt
Created October 17, 2016 21:09
Amazon Problems
Coding question: Write a function to check if a binary tree is a sum tree. Here, sum tree is defined as a binary tree in which every node's value equals the sum of values of left and right child nodes. (Leaf nodes can have any value).
Problem solving question: Given an array comprising odd number of non-negative integers, you have to remove one element from it and divide the remaining array into two arrays of equal size, such that their sum of elements are also equal. If such a partition is not possible, you have to determine that. If such a partition is possible you have to identify one possible solution. How do you go about solving such a problem.
@codegagan
codegagan / First.sc
Created January 21, 2018 06:44
Scala Worksheet
println("Hello Thoughtworks !")
val numbers = List(1,2,3,4);
numbers.map(x=> x+1).reduce(_+_);
val squareOf = (x:Int, y:Int) =>x*y
squareOf(4,5)
@codegagan
codegagan / TestClass.java
Created August 20, 2018 09:21
Tree Diameter problem
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;