Software Development and Programming Careers (Official Discussion Thread)

Joined
Apr 3, 2014
Messages
71,910
Reputation
17,058
Daps
305,943
Also @Neo The Resurrected ONE here's one for you: write a function that validates matching parentheses/braces/brackets.
Input: ()
Output: true
Input: {[]}()
Output: true
Input: (})
Output: false

You can assume the input will only contain a combination of ()[]{}.




Seems simple enough :ohhh:

Will do it when I get home later today
 
Joined
Apr 3, 2014
Messages
71,910
Reputation
17,058
Daps
305,943
Also @Neo The Resurrected ONE here's one for you: write a function that validates matching parentheses/braces/brackets.
Input: ()
Output: true
Input: {[]}()
Output: true
Input: (})
Output: false

You can assume the input will only contain a combination of ()[]{}.







:pacspit::pacspit::pacspit:





































I forgot about this until a few min ago and I sat down to solve it, thought I had it done in 5 min but then I see it ain't as easy as it looks :bryan::bryan::bryan:

I love it :bryan:


I know what I need to do tho. I'm working on it now.
 
Joined
Apr 3, 2014
Messages
71,910
Reputation
17,058
Daps
305,943
Also @Neo The Resurrected ONE here's one for you: write a function that validates matching parentheses/braces/brackets.
Input: ()
Output: true
Input: {[]}()
Output: true
Input: (})
Output: false

You can assume the input will only contain a combination of ()[]{}.




Alright, breh, I got it.

This is my JavaScript solution.

Code:
function matchInput (a) {
  let b;
  let c;
  a.toString('');
  if (a.includes('(') && a.includes('[') && a.includes('{') )  {
    if (a.includes(')') && a.includes(']') && a.includes('}')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes('(') && a.includes('[')) {
    if (a.includes(')') && a.includes(']')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes('(') && a.includes('{')) {
    if (a.includes(')') && a.includes('}')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes('{') && a.includes('[')) {
    if (a.includes('}') && a.includes(']')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes(')') && a.includes(']') && a.includes('}') )  {
    if (a.includes('(') && a.includes('[') && a.includes('{')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes(')') && a.includes(']')) {
    if (a.includes('(') && a.includes('[')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes(')') && a.includes('}')) {
    if (a.includes('(') && a.includes('{')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes('}') && a.includes(']')) {
    if (a.includes('{') && a.includes('[')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes(')')) {
    if (a.includes('(')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if(a.includes('}')) {
    if (a.includes('{')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if(a.includes(']')) {
    if(a.includes('[')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes('(')) {
    if (a.includes(')')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if(a.includes('{')) {
    if (a.includes('}')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if(a.includes('[')) {
    if(a.includes(']')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else {
    return false;
  }
  if(b && c ) {
  return true;
  } else {
    return false;
 }
}
 

DJSmooth

Superstar
Joined
Oct 22, 2015
Messages
3,938
Reputation
1,219
Daps
23,579
Alright, breh, I got it.

This is my JavaScript solution.

Code:
function matchInput (a) {
  let b;
  let c;
  a.toString('');
  if (a.includes('(') && a.includes('[') && a.includes('{') )  {
    if (a.includes(')') && a.includes(']') && a.includes('}')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes('(') && a.includes('[')) {
    if (a.includes(')') && a.includes(']')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes('(') && a.includes('{')) {
    if (a.includes(')') && a.includes('}')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes('{') && a.includes('[')) {
    if (a.includes('}') && a.includes(']')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes(')') && a.includes(']') && a.includes('}') )  {
    if (a.includes('(') && a.includes('[') && a.includes('{')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes(')') && a.includes(']')) {
    if (a.includes('(') && a.includes('[')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes(')') && a.includes('}')) {
    if (a.includes('(') && a.includes('{')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes('}') && a.includes(']')) {
    if (a.includes('{') && a.includes('[')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes(')')) {
    if (a.includes('(')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if(a.includes('}')) {
    if (a.includes('{')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if(a.includes(']')) {
    if(a.includes('[')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes('(')) {
    if (a.includes(')')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if(a.includes('{')) {
    if (a.includes('}')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if(a.includes('[')) {
    if(a.includes(']')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else {
    return false;
  }
  if(b && c ) {
  return true;
  } else {
    return false;
 }
}

LOL this is wayyyy too much code. If it feels like it's too much code it probably is.
 

jajahoe

Rookie
Joined
May 5, 2012
Messages
156
Reputation
10
Daps
362
Reppin
KIlleen, TX
Alright, breh, I got it.

This is my JavaScript solution.

Code:
function matchInput (a) {
  let b;
  let c;
  a.toString('');
  if (a.includes('(') && a.includes('[') && a.includes('{') )  {
    if (a.includes(')') && a.includes(']') && a.includes('}')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes('(') && a.includes('[')) {
    if (a.includes(')') && a.includes(']')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes('(') && a.includes('{')) {
    if (a.includes(')') && a.includes('}')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes('{') && a.includes('[')) {
    if (a.includes('}') && a.includes(']')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if (a.includes(')') && a.includes(']') && a.includes('}') )  {
    if (a.includes('(') && a.includes('[') && a.includes('{')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes(')') && a.includes(']')) {
    if (a.includes('(') && a.includes('[')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes(')') && a.includes('}')) {
    if (a.includes('(') && a.includes('{')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes('}') && a.includes(']')) {
    if (a.includes('{') && a.includes('[')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes(')')) {
    if (a.includes('(')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if(a.includes('}')) {
    if (a.includes('{')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if(a.includes(']')) {
    if(a.includes('[')) {
      c = true;
      b = true;
    } else {
      c = false;
      b = false;
    }
  } else if (a.includes('(')) {
    if (a.includes(')')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if(a.includes('{')) {
    if (a.includes('}')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else if(a.includes('[')) {
    if(a.includes(']')) {
      b = true;
      c = true;
    } else {
      b = false;
      c = false;
    }
  } else {
    return false;
  }
  if(b && c ) {
  return true;
  } else {
    return false;
 }
}


Yea, this is way to much code man. When you see problems like this first thing you should do is think if there is any data structure that can help solve this problem. For this problem a stack would make the solution way easier.
 
Joined
Apr 3, 2014
Messages
71,910
Reputation
17,058
Daps
305,943
LOL this is wayyyy too much code. If it feels like it's too much code it probably is.


Yea, this is way to much code man. When you see problems like this first thing you should do is think if there is any data structure that can help solve this problem. For this problem a stack would make the solution way easier.




I haven't made it to data structures yet :lupe:


Im still learning :lupe:


My solution is long but it does work right?:lupe:
 

69 others

Superstar
Joined
May 2, 2012
Messages
6,505
Reputation
716
Daps
24,036
Reppin
NULL
Not sure if this was posted before but Meta has a boot camp style 1 year rotational program for engineers with 2+ years of experience. underrepresented minorities are encouraged to apply. From what i hear it's a leetcode style interview but a bit easier. After successful completion of the program, you'll match into a team at the E4 level.

Rotational Software Engineer
 

Mike809

Veteran
Supporter
Joined
Oct 15, 2015
Messages
16,098
Reputation
3,651
Daps
82,102
Reppin
Bronx
Heres a coding problem that doesnt require a data structure. Just string manipulation.

Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its left and right are gone.
So "ab*cd" yields "ad"
and "ab**cd" also yields "ad".

example outputs:
starOut("ab*cd") → "ad"
starOut("ab**cd") → "ad"
starOut("sm*eilly") → "silly"
 
Top