Skip to content

Instantly share code, notes, and snippets.

View preetb123's full-sized avatar

Preetam Bhosle preetb123

View GitHub Profile
const s = "Dealing with failure is easy: Work hard to improve. Success is also easy to handle: You’ve solved the wrong problem. Work hard to improve"
function sumOfSentence(input: string){
const vowels = new Set(['a','e','i','o','u'])
let sum = 0;
for(let i=0; i<input.length; i++){
const character = input.charAt(i);
const asciiValue = input.charCodeAt(i)
if(asciiValue >= 65 && asciiValue <= 90 || asciiValue >= 97 && asciiValue <= 122){
if(vowels.has(character.toLowerCase())){
sum -= asciiValue;
// given sorted array of numbers, find pair that sums to the target OR is closest to the target number
function findPair(a: number[], target: number): number[][]{
let start = 0;
let end = a.length - 1
let result: number[][] = []
// if we have two values that are at the same distance from the target,
// then array will contain both values, else it will only contain value that is nearer
let nearByValues: number[][] = []
let diff = Number.MAX_SAFE_INTEGER
@preetb123
preetb123 / vscode-settings
Created March 18, 2020 10:00
Latest VSCode Settings
We couldn’t find that file to show.
import React from "react";
import RX, { Text, Component, View, Modal } from "reactxp";
// import { App } from './App';
import { DEBUG, DEV } from "./config";
import Navigator, {
NavigatorDelegateSelector as DelegateSelector,
Types
} from "reactxp-navigation";
# creates a deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: gql-server-deployment
labels:
app: simple-graphql-server
spec:
replicas: 3
template:
@preetb123
preetb123 / MongoDB_macOS_Sierra.md
Created February 5, 2018 12:02 — forked from nrollr/MongoDB_macOS_Sierra.md
Install MongoDB on Sierra using Homebrew

Install MongoDB on macOS Sierra

This procedure explains how to install MongoDB using Homebrew on macOS Sierra 10.12.
Official MongoDB install documentation: here

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner scan = new Scanner(System.in);
int noOfTestCases = scan.nextInt();
int[][] input = new int[noOfTestCases][2];
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner scan = new Scanner(System.in);
int numTestCases = scan.nextInt();
int[] input = new int[numTestCases];
@preetb123
preetb123 / The Technical Interview Cheat Sheet.md
Created March 2, 2017 21:30 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@preetb123
preetb123 / exp_eval.js
Last active December 20, 2016 16:08
Simple expression evaluator in javascript
/*
isValid('{{()}}') = true
isValid('{{(]]}') = false
isValid('(({{()}}))') = true
isValid('(({{(}}))') = false
isValid('(({{()()}}))') = true
*/
function isValid(expression){
let stack = [];