Skip to content

Instantly share code, notes, and snippets.

View vikashvverma's full-sized avatar
🎯
Focusing

Vikash Verma vikashvverma

🎯
Focusing
View GitHub Profile
@vikashvverma
vikashvverma / Bubble Sort - C Program Source Code
Created January 30, 2013 22:03
Bubble Sort It’s a sorting algorithm, in which each pair of adjacent items are compared and swapped if they are in wrong order. The comparison is repeated until no swaps are needed, indicating that the list is sorted. The smaller elements ‘bubble’ to the top of the list, hence, the name Bubble Sort. In this like selection sort, after every pass …
#include<stdio.h>
/* Logic : Do the following thing until the list is sorted
(i) Compare two adjacent elements and check if they are in correct order(that is second one has
to be greater than the first).
(ii) Swap them if they are not in correct order.
*/
void BubbleSort(int *array,int number_of_elements)
{
int iter, temp, swapped;
do
@vikashvverma
vikashvverma / Facebook Hacker Cup 2013 Solution : Balanced Smileys
Last active July 4, 2019 02:36
This is my solution for Facebook Hacker Cup 2013 in java :Balanced Smileys
The problem statement is given below:
Your friend John uses a lot of emoticons when you talk to him on Messenger. In addition to being a person who likes to express himself through emoticons, he hates unbalanced parenthesis so much that it makes him go :(
Sometimes he puts emoticons within parentheses, and you find it hard to tell if a parenthesis really is a parenthesis or part of an emoticon.
A message has balanced parentheses if it consists of one of the following:
1. An empty string ""
2. One or more of the following characters: 'a' to 'z', ' ' (a space) or ':' (a colon)
3. An open parenthesis '(', followed by a message with balanced parentheses, followed by a close parenthesis ')'.
4. A message with balanced parentheses followed by another message with balanced parentheses.
@vikashvverma
vikashvverma / Facebook Hacker Cup 2013 Beautiful Strings solution in java
Last active June 23, 2019 09:42
This is my implementation in java for Facebook Hacker Cup 2013 for Beautiful Strings problem
//visit http://vikash-thiswillgoaway.blogspot.com for solution of other problems
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.Collections;
/**
*