Skip to content

Instantly share code, notes, and snippets.

View vinay13's full-sized avatar
🎯
Focusing

Vinay Singh vinay13

🎯
Focusing
View GitHub Profile
@vinay13
vinay13 / seclarge.c
Created February 16, 2014 00:06
second largest no w/o sorting
//find the second best
#include<stdio.h>
int main()
{
int a[7]={1,8,5,7,10,11,2};
int max,sec_max;
@vinay13
vinay13 / mirrortree.c
Created February 16, 2014 00:09
mirror image of binary tree
#include<stdio.h>
#include<malloc.h>
struct node
{
int data;
struct node* left;
struct node* right;
};
@vinay13
vinay13 / keypad
Created August 9, 2014 13:46
keypad character corressponding number
#include <stdio.h>
#include <string.h>
// hashTable[i] stores all characters that correspond to digit i in phone
const char hashTable[10][5] = {"", "", "abc", "def", "ghi", "jkl",
"mno", "pqrs", "tuv", "wxyz"};
// A recursive function to print all possible words that can be obtained
// by input number[] of size n. The output words are one by one stored
// in output[]
@vinay13
vinay13 / queue2stack
Created August 10, 2014 14:42
implement queue using 2 stack
#include<stdio.h>
#include<stdlib.h>
/* structure of a stack node */
struct sNode
{
int data;
struct sNode *next;
};
@vinay13
vinay13 / q2stack.c
Created August 10, 2014 14:44
queue 2 stack
#include<stdio.h>
#include<stdlib.h>
/* structure of a stack node */
struct sNode
{
int data;
struct sNode *next;
};
@vinay13
vinay13 / deleteBST.c
Created August 13, 2014 08:01
binary search tree deletion
#include<stdio.h>
#include<stdlib.h>
struct node
{
int key;
struct node *left, *right;
};
// A utility function to create a new BST node
@vinay13
vinay13 / phoneWord2No.c
Created August 25, 2014 18:53
keypadChar to no
//hashmap phone keypad
#include <stdio.h>
#include <string.h>
int main()
{
char str[]="facebook";
@vinay13
vinay13 / 2ndmin.c
Created August 26, 2014 18:28
Find the smallest and second smallest element in an array
#include <stdio.h>
#include <limits.h> /* For INT_MAX */
/* Function to print first smallest and second smallest elements */
void print2Smallest(int arr[], int arr_size)
{
int i, first, second;
/* There should be atleast two elements */
if (arr_size < 2)
@vinay13
vinay13 / nonrep.c
Created August 27, 2014 21:39
first non-repeating character in a string
//first non repeating chaarcter in a string
#include <stdio.h>
#include <string.h>
char firstNon(char str[])
{
int count[256]={0};
int i;
@vinay13
vinay13 / maxweight.c
Created August 27, 2014 23:57
given a binary tree where each node has some weight. You have to return the max weight in the binary tree.
//binary tree where each node has some weight.
//you have to return the max weight int the binary tree
#include <stdio.h>
#include <malloc.h>
struct node
{
int data;