Skip to content

Instantly share code, notes, and snippets.

View viveknarang's full-sized avatar
🇨🇦
O Canada!

Vivek Narang viveknarang

🇨🇦
O Canada!
  • Toronto, Canada
View GitHub Profile
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.stream.Collectors;
/**
* Suppose you have a comma-separated list of merchants, the platforms they’re on,
/**
* This function estimates the average of two six-digit hexadecimal colors.
* The function assumes that the inputs are valid.
* @param {*} color1 // first hexadecimal color
* @param {*} color2 // second hexadecimal color
* @author Vivek Narang
*/
function avgColor(color1, color2) {
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.
An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers.
Question: https://leetcode.com/problems/sum-root-to-leaf-numbers/
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
class Solution {
public boolean isIsomorphic(String s, String t) {
if (s.length() != t.length()) {
return false;
}
Map<Character, Character> aMap = new HashMap<Character, Character>();
Map<Character, Character> bMap = new HashMap<Character, Character>();
package edu.uga;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
thisApt = null;
for (int i = 0 ; i < apts.length ; i++) {
if (apts[i].getAptID() == theAptID) {
thisApt = apts[i];
break;
}
}
if (thisApt == null) {
public void printEmpData(int id)
{
boolean exists = false;
System.out.println("ID" + " " + "Name" + " " + "Hours" + " " + "Salary");
System.out.println("-------------------------");
for(int i = 0; i < employeePayroll.length; i++) {
if (employeePayroll[i].getId() == id) {
exists = true;
import java.util.Scanner;
public class ArraysKeyValue {
public static void main (String [] args) {
final int NUM_ROWS = 2;
final int NUM_COLS = 2;
int [][] milesTracker = new int[NUM_ROWS][NUM_COLS];
int i;
int j;
int maxMiles; // Assign with first element in milesTracker before loop
import java.util.Scanner;
public class FindMatchValue {
public static void main (String [] args) {
final int NUM_VALS = 4;
int[] userValues = new int[NUM_VALS];
int i;
int matchValue;
int numMatches = -99; // Assign numMatches with 0 before your for loop
public class OOPExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
Numbers num = new Numbers(1, 2);
System.out.println(num.sum());
Numbers num2 = new Numbers();