<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: A Programming Job Interview Challenge #13 Follow up</title>
	<atom:link href="http://dotnetchris.wordpress.com/2008/07/31/a-programming-job-interview-challenge-13-follow-up/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotnetchris.wordpress.com/2008/07/31/a-programming-job-interview-challenge-13-follow-up/</link>
	<description>C# ASP.Net Development Weblog</description>
	<lastBuildDate>Sun, 02 Jun 2013 23:47:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Khalid Abuhakmeh</title>
		<link>http://dotnetchris.wordpress.com/2008/07/31/a-programming-job-interview-challenge-13-follow-up/#comment-27</link>
		<dc:creator><![CDATA[Khalid Abuhakmeh]]></dc:creator>
		<pubDate>Thu, 31 Jul 2008 17:50:43 +0000</pubDate>
		<guid isPermaLink="false">http://dotnetchris.wordpress.com/?p=13#comment-27</guid>
		<description><![CDATA[The same example, but mine goes through the whole string instead. Great Job. I am amazed we came to the same type of conclusion.

&lt;code&gt;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Interperter
{
    class Program
    {
        static Dictionary Language;

        static void Main(string[] args)
        {
            InitiailzeLanguage();

            string validString = &quot;([]())&quot;;
            string inValidString = &quot;({}&quot;;

            bool isValid = ValidateLanguage(validString);
            bool isInvalid = ValidateLanguage(inValidString);
        }

        private static bool ValidateLanguage(IEnumerable toValidate)
        {
            Stack characters = new Stack();

            foreach (char item in toValidate)
            {
                if (characters.Count &gt; 0 &amp;&amp;              // make sure the stack is not empty
                    Language.ContainsKey(item) &amp;&amp;        // make sure the character is the closing character
                    characters.Peek() == Language[item]) // see if the opening tag is top most on stack
                    characters.Pop();                    // pop if we have success!
                else
                    characters.Push(item);               // didn&#039;t match, push on stack to try later
            }

            return characters.Count == 0;
        }

        private static void InitiailzeLanguage()
        {
            Language = new Dictionary();

            Language.Add( &#039;)&#039;, &#039;(&#039;);
            Language.Add( &#039;]&#039;, &#039;[&#039;);
            Language.Add( &#039;}&#039;, &#039;{&#039;);
            Language.Add( &#039;&gt;&#039;, &#039;&lt;&#039; );
        }
    }
}
&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>The same example, but mine goes through the whole string instead. Great Job. I am amazed we came to the same type of conclusion.</p>
<p><code><br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;</p>
<p>namespace Interperter<br />
{<br />
    class Program<br />
    {<br />
        static Dictionary Language;</p>
<p>        static void Main(string[] args)<br />
        {<br />
            InitiailzeLanguage();</p>
<p>            string validString = "([]())";<br />
            string inValidString = "({}";</p>
<p>            bool isValid = ValidateLanguage(validString);<br />
            bool isInvalid = ValidateLanguage(inValidString);<br />
        }</p>
<p>        private static bool ValidateLanguage(IEnumerable toValidate)<br />
        {<br />
            Stack characters = new Stack();</p>
<p>            foreach (char item in toValidate)<br />
            {<br />
                if (characters.Count &gt; 0 &amp;&amp;              // make sure the stack is not empty<br />
                    Language.ContainsKey(item) &amp;&amp;        // make sure the character is the closing character<br />
                    characters.Peek() == Language[item]) // see if the opening tag is top most on stack<br />
                    characters.Pop();                    // pop if we have success!<br />
                else<br />
                    characters.Push(item);               // didn't match, push on stack to try later<br />
            }</p>
<p>            return characters.Count == 0;<br />
        }</p>
<p>        private static void InitiailzeLanguage()<br />
        {<br />
            Language = new Dictionary();</p>
<p>            Language.Add( ')', '(');<br />
            Language.Add( ']', '[');<br />
            Language.Add( '}', '{');<br />
            Language.Add( '&gt;', '&lt;' );<br />
        }<br />
    }<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
