This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Given a String of length N reverse the words in it. Words are separated by dots. | |
| By : Varun Thakur | |
| Date : 31/07/2017 | |
| */ | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| void reverse(char *begin, char *end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Given an expression string exp , write a program to examine whether | |
| the pairs and the orders of “{“,”}”,”(“,”)”,”[“,”]” are correct in exp. | |
| For example, the program should print true for exp = “[()]{}{[()()]()}” | |
| and false for exp = “[(])” | |
| By : Varun Thakur | |
| Date : 31/07/2017 | |
| */ | |
| #include <stack> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Write an efficient C program to find the sum of contiguous subarray | |
| within a one-dimensional array of numbers which has the largest sum. | |
| */ | |
| #include <iostream> | |
| using namespace std; | |
| int kadaneAlgo(int arr[],int n) | |
| { | |
| if(n==1) | |
| return arr[0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| K Largest Elements | |
| Given an array, print k largest elements from the array. | |
| The output elements should be printed in decreasing order. | |
| By : Varun Thakur | |
| Dated : 27/07/2017 | |
| */ | |
| #include <bits/stdc++.h> | |
| using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| #define MAX_SIZE 100 | |
| void printParentheses(int n); | |
| void _printParentheses(int pos, int n, int open, int close); | |
| void printParentheses(int n) | |
| { | |
| if(n>0) | |
| _printParentheses(0,n,0,0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Pascal’s triangle is a triangular array of the binomial coefficients. | |
| Write a function that takes an integer value n as input and prints | |
| first n lines of the Pascal’s triangle. Following are the first 6 | |
| rows of Pascal’s Triangle. | |
| */ | |
| #include <iostream> | |
| using namespace std; | |
| int binomialCoefficient(int, int); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| static char *rand_string(char *str, size_t size) | |
| { | |
| const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJK..."; | |
| if (size) { | |
| --size; | |
| for (size_t n = 0; n < size; n++) { | |
| int key = rand() % (int) (sizeof charset - 1); | |
| str[n] = charset[key]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| import java.lang.*; | |
| import java.io.*; | |
| class RunLengthCoding | |
| { | |
| public static void main (String[] args) throws java.lang.Exception | |
| { | |
| // your code goes here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| void pattern1(int n){ | |
| int cnt=1; | |
| for(int i=0; i<2*n-1; i++){ | |
| for(int j=0; j<(abs(n-1-i)); j++)cout<<" "; | |
| for(int j=0; j<2*(n-abs(n-1-i))-1; j++)cout<<cnt++; | |
| cout<<endl; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.company; | |
| import java.util.Arrays; | |
| import java.util.Scanner; | |
| import static java.util.Arrays.binarySearch; | |
| public class EXTRAN { | |