Skip to content

Instantly share code, notes, and snippets.

View pavelnganpi's full-sized avatar

pavey nganpi pavelnganpi

  • truex
  • World
View GitHub Profile
public class Stack {
int top;
int[] stackA;
int size;
public Stack(int size){
stackA = new int[size];
top = -1;
this.size=size;
package test;
public class Queue {
int size;
int[] queueA;
int top;
int rear;
public Queue(int size){
package test;
public class Link {
public static class LinkedList<E>{
public class Node<E>{
E elem;
Node<E> next,previous;
}
@pavelnganpi
pavelnganpi / ArraySumSubsequence.c++
Created July 18, 2014 12:34
find 3 size subseq whose product is max
//Max Product of three item subseq
//output 6 8 9
//Max Prod = 432
#include<iostream>
using namespace std;
int Max(int i, int j)
{
package test;
public class StringToInt {
public static int strToInt( String str ){
int i = 0;
int num = 0;
boolean isNeg = false;
package test;
public class StringToInt {
public static String IntToString( int num ){
int rem = 0;
int div = 0;
StringBuilder sb = new StringBuilder();
while(num !=0){
rem = num%10;
@pavelnganpi
pavelnganpi / LargestMultipleOfThree.java
Created July 19, 2014 01:59
Given an array of non-negative integers. Find the largest multiple of 3 that can be formed from array elements. For example, if the input array is {8, 1, 9}, the output should be “9 8 1″, and if the input array is {8, 1, 7, 6, 0}, output should be “8 7 6 0″.
package test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
public class LargeMultipleThree {
@pavelnganpi
pavelnganpi / infixToPostfix.java
Created July 19, 2014 19:47
convert an infix expression to postfix
package test;
import java.util.Stack;
public class InfixToPostfix {
//checks for the priority of an operator
public static int priority(char ch){
switch(ch){
@pavelnganpi
pavelnganpi / EvalatePostfix.java
Last active August 29, 2015 14:04
given a postfix mathematical expression, evaluate it
package test;
import java.util.Stack;
public class EvaluatePostfix {
public static int solution(String postfix){
Stack<Integer> stack = new Stack<Integer>();
int sum = 0;
package test;
public class MergeSort {
private static void mergesort(int[] arr, int n) {
int mid;
int[] left;