Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
struct box
{
int h,w,d;
};
bool comp(box a,box b)
@nups
nups / longesteven.cpp
Created November 6, 2015 06:34
microsoft:length of longest even length substring
#include<bits/stdc++.h>
using namespace std;
int findLength(string str, int n)
{
int sum[n]={0},max=INT_MIN;
sum[0]=str[0]-48;
for(int i=1;i<n;i++)
{
sum[i]=sum[i-1]+str[i]-48;
// A simple C based program to find length of longest even length
// substring with same sum of digits in left and right
#include<stdio.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
int findLength(string s)
{
long long int max=INT_MIN;
@nups
nups / connectdll.cpp
Created November 5, 2015 16:22
Extract Leaves of a Binary Tree in a Doubly Linked List
#include <stdio.h>
#include <stdlib.h>
// Structure for tree and linked list
struct Node
{
int data;
struct Node *left, *right;
};
@nups
nups / kdistancefar.cpp
Created November 5, 2015 16:02
Print all nodes at distance k from a given node
#include <iostream>
using namespace std;
// A binary Tree node
struct node
{
int data;
struct node *left, *right;
};
@nups
nups / priorityqueue.cpp
Created November 4, 2015 17:51
flipkart hospital wal que
#include<queue>
#include<iostream>
#include<vector>
using namespace std;
struct node
{
int p,i;
};
@nups
nups / anagra.cpp
Created November 4, 2015 13:49
flipkart set 37
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
string s;
cin>>s;
int n=s.size();
map<char,int> my;
for(int i=0;i<n/2;i++)
@nups
nups / andrewguess.cpp
Created November 3, 2015 06:25
inmobi:andrew guess
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
struct gr
{
int guess,cor;
};
int main()
{
@nups
nups / election.cpp
Created November 3, 2015 05:29
Inmobi:There are elections in town. Each candidate has been voted. A[1…n] is the array where A[i] denotes the the number of votes for the the ith candidate. This array A[] is sorted in descending order with ties broken by increasing indices. You can increase the votes for any candidate and also you have a desire list for the candidate. Rank[1…n]…
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
struct gr
{
int x,y;
};
@nups
nups / trieuniquematrix.cpp
Last active November 2, 2015 16:21
print unique rows in a matrix
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include<iostream>
using namespace std;
#define ROW 4
#define COL 5
struct node