Skip to content

Instantly share code, notes, and snippets.

View abhinavnigam2207's full-sized avatar
๐Ÿ˜Ž

Abhinav Nigam abhinavnigam2207

๐Ÿ˜Ž
View GitHub Profile
@abhinavnigam2207
abhinavnigam2207 / castle-global.js
Last active May 9, 2018 12:02
String matching time complexity problem (Asked in Castle Global)
const problemSolution = function(str){
let val = str.split(''),
stack = [],
count = 0;
stack.push(val[0]);
for(let i=1; i< val.length; i++) {
if((/[a-z]/.test(stack[stack.length-1])) && (/[a-z]/.test(val[i]))) {
console.log('1'+ val[i]);
return count;
}
@abhinavnigam2207
abhinavnigam2207 / check-duplicates-in-array-by-property.js
Last active September 6, 2017 06:05
Check duplicates in an array by property and mark duplicates with a boolean flag.
const myArray = [
{id: 1, name: 'Abhinav', email: '[email protected]'},
{id: 2, name: 'Aviral', email: '[email protected]'},
{id: 3, name: 'Jitendra', email: '[email protected]'},
{id: 4, name: 'Rajesh', email: '[email protected]'},
{id: 5, name: 'Abhinav', email: '[email protected]'},
{id: 6, name: 'Akash', email: '[email protected]'},
];
let arrayCopy = JSON.parse(JSON.stringify(myArray));
@abhinavnigam2207
abhinavnigam2207 / bracket-problem.js
Created February 22, 2017 13:08
Bracket Problem (Asked in Toptal Interview )
'use strict';
function solution(S) {
var arr = [];
var K = 0;
for (var i=0; i<S.length; i++) {
if (S[i]=='(') {
arr.push(S[i]);
} else {
if(arr.length){