tag:blogger.com,1999:blog-2078411165009494412024-02-19T08:06:33.369-08:00Code ZoneSudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.comBlogger863125tag:blogger.com,1999:blog-207841116500949441.post-48517080201913397392018-02-14T15:54:00.002-08:002018-02-14T15:54:19.605-08:00Design Build System<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; box-sizing: border-box; margin-bottom: 10px;">
<span style="color: #333333; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">Could you please add more information and context to your question?</span></div>
<div style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 10px;">
For example, what does the build system have to support?</div>
<ul style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 10px; margin-top: 0px;">
<li style="box-sizing: border-box; list-style-type: disc;"><div style="box-sizing: border-box; margin-bottom: 10px;">
Only the compilation of source files? Or also dependency management? Or continuous integration (like Jenkins)?</div>
</li>
<li style="box-sizing: border-box; list-style-type: disc;"><div style="box-sizing: border-box; margin-bottom: 10px;">
Only a particular language or it has to support many languages / platforms? For example, <a href="https://ant.apache.org/" rel="nofollow" style="-webkit-tap-highlight-color: transparent; background-color: transparent; box-sizing: border-box; color: #337ab7; text-decoration-line: none;">Ant</a> is a popular build system for Java. And of course there is <a href="https://bazel.build/" rel="nofollow" style="-webkit-tap-highlight-color: transparent; background-color: transparent; box-sizing: border-box; color: #337ab7; text-decoration-line: none;">Bazel</a> which is powerful and supports many languages and platforms.</div>
</li>
<li style="box-sizing: border-box; list-style-type: disc;"><div style="box-sizing: border-box; margin-bottom: 10px;">
Used by how many developers? Does it need to be distributed?</div>
</li>
<li style="box-sizing: border-box; list-style-type: disc;"><div style="box-sizing: border-box; margin-bottom: 10px;">
How about dependency management? Assuming there are some way to specify explicit dependencies and the build system is able to identify which resources that need to be rebuild upon a change of some components (i.e., via a DAG).</div>
</li>
</ul>
<div style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 10px;">
Feel free to add more if there's something that I missed.</div>
<div style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 10px;">
Some other requirements to consider:</div>
<ul style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 10px; margin-top: 0px;">
<li style="box-sizing: border-box; list-style-type: disc;">Handle versioning? For example, in web development, the htmls need to refer to the correct versions of .js and .css files</li>
<li style="box-sizing: border-box; list-style-type: disc;">Deal with secrets? For example, if the source code refer to some key or connection strings, does the build system need to plug-in the correct values for different environments?</li>
<li style="box-sizing: border-box; list-style-type: disc;">Authentication for users? Is the system a product like VSTS/visualstudioonline or is it an internal service?</li>
</ul>
<div>
<a href="https://discuss.leetcode.com/topic/119500/design-a-build-system" style="background-color: white; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px;">https://discuss.leetcode.com/topic/119500/design-a-build-system</a></div>
</div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-10626607258725928562018-02-14T15:52:00.001-08:002018-02-14T15:52:07.627-08:00Cache vs. Session Store: How we can use Redis for both?<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<a href="https://discuss.leetcode.com/topic/120202/cache-vs-session-store-how-we-can-use-redis-for-both">https://discuss.leetcode.com/topic/120202/cache-vs-session-store-how-we-can-use-redis-for-both</a><br />
<a href="https://redislabs.com/blog/cache-vs-session-store/">https://redislabs.com/blog/cache-vs-session-store/</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-47386296894673050372018-02-14T15:51:00.000-08:002018-02-14T15:51:03.253-08:00Duration of Skype Call per Day<div dir="ltr" style="text-align: left;" trbidi="on">
<h1 class="hidden-xs" component="post/header" itemprop="name" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 36px; font-weight: 500; line-height: 40px; margin: 0px 0px 30px;">
<span class="topic-title" component="topic/title" style="box-sizing: border-box; color: inherit; display: inline-block; font-size: 28px; line-height: 32px; margin-top: 8px; overflow: hidden; text-transform: initial; word-wrap: break-word;">Design a system to caculate the duration of the average skype call per day</span></h1>
</div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-54972641218057588192017-04-21T02:40:00.001-07:002017-04-21T02:40:28.285-07:00Design a News Feed System like Facebook<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://blog.gainlo.co/index.php/2016/03/29/design-news-feed-system-part-1-system-design-interview-questions/">http://blog.gainlo.co/index.php/2016/03/29/design-news-feed-system-part-1-system-design-interview-questions/</a><br />
<a href="https://www.blogger.com/goog_637865753"><br /></a><a href="http://blog.gainlo.co/index.php/2016/04/05/design-news-feed-system-part-2/">http://blog.gainlo.co/index.php/2016/04/05/design-news-feed-system-part-2/</a><br />
<br />
<a href="https://www.quora.com/What-are-the-best-practices-for-building-something-like-a-News-Feed">https://www.quora.com/What-are-the-best-practices-for-building-something-like-a-News-Feed</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-56023002074708041322017-04-20T04:49:00.001-07:002017-04-20T04:49:19.513-07:00Design a Facebook like status system <div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://stackoverflow.com/questions/7072924/what-is-the-design-architecture-behind-facebooks-status-update-mechanism" style="font-family: "trebuchet ms"; font-size: 14.6667px; text-decoration-line: none; white-space: pre-wrap;">http://stackoverflow.com/questions/7072924/what-is-the-design-architecture-behind-facebooks-status-update-mechanism</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-64083110398850686882016-11-09T09:46:00.002-08:002016-11-09T09:46:20.995-08:00Design a Coffee Shop<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 class="post-title entry-title" style="background-color: white; color: #222222; font-family: arial, tahoma, helvetica, freesans, sans-serif; font-size: 22px; font-stretch: normal; font-weight: normal; margin: 0.75em 0px 0px; position: relative;">
OO design for a coffee shop</h3>
<div>
<a href="https://www.blogger.com/goog_18711050"><br /></a></div>
<div>
<a href="http://massivetechinterview.blogspot.in/2015/07/thought-works-oo-design-for-coffee-shop.html">http://massivetechinterview.blogspot.in/2015/07/thought-works-oo-design-for-coffee-shop.html</a></div>
</div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-54264190940782124322016-11-09T09:45:00.002-08:002016-11-09T09:45:43.611-08:00Design a Tic Tac Toe Game <div dir="ltr" style="text-align: left;" trbidi="on">
Write me a function for the game of tic-tac-toe in C<br />
<br />
<u><b>Useful Links:</b></u><br />
<a href="http://www.codercaste.com/2011/01/26/how-to-code-a-tic-tac-toe-game-in-c-including-artificial-intelligence-opponent/">http://www.codercaste.com/2011/01/26/how-to-code-a-tic-tac-toe-game-in-c-including-artificial-intelligence-opponent/</a><br />
<a href="http://stackoverflow.com/questions/6572194/review-my-design-tic-tac-toe-game-using-oo-methodology">http://stackoverflow.com/questions/6572194/review-my-design-tic-tac-toe-game-using-oo-methodology</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-4680386557206429352016-11-09T09:42:00.001-08:002016-11-09T09:42:50.508-08:00Efficient data structure for storing and calculating the total resistance<div dir="ltr" style="text-align: left;" trbidi="on">
Given a Circuit (with resistors), we need to calculate the total resistance. Input will be like AB-5ohm, BC-6ohm, BC-10ohm, BC-20 ohm, CD-5 ohm. BC has been repeated twice implying they are in series. "<b>Write a program by implementing efficient data structure for storing and calculating the total resistance</b></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-77892060492514600542016-11-06T08:38:00.000-08:002016-11-06T08:38:01.745-08:00Design a Chess Game<div dir="ltr" style="text-align: left;" trbidi="on">
Object oriented design for chess game<br />
<br />
Object Oriented design represents the real world objects in code.<br />
<br />
<a href="https://xmruibi.gitbooks.io/interview-preparation-notes/content/OOD/DesignExamples/ChessGame.html">https://xmruibi.gitbooks.io/interview-preparation-notes/content/OOD/DesignExamples/ChessGame.html</a><br />
<br />
<a href="http://massivetechinterview.blogspot.in/2015/07/design-chess-game-using-oo-principles.html">http://massivetechinterview.blogspot.in/2015/07/design-chess-game-using-oo-principles.html</a><br />
<div>
<br /></div>
</div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-37688037878942042842016-11-03T01:19:00.001-07:002016-11-03T01:19:52.692-07:00Sort the Result Array<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
We have an integer array that is sorted in ascending order. We also have 3 ints A, B and C. We need to apply A*x*x + B*x + C for each element x in the array and return the corresponding sorted array.<br />
<br />
Example: Input array = -1 0 1 2 3 4 and A = -1, B = 2, C = -1<br />
Result of applying the formula to each element = -4 -1 0 -1 -4 -9<br />
So expected result = -9 -4 -4 -1 -1 0 (sorted)<br />
<br />
Time complexity :o(n), no extra space<br />
<br />
<b><u>Method: Parabolic Property</u></b><br />
The equation given is parabolic. So the result of applying it to a sorted array will result in an array that will have a maximum/minimum with the sub-arrays to its left and right sorted.<br />
<br />
In your case the maximum is 0 and the sub array to its left [-4 -1] is sorted in ascending order and the sub-array to its right [-1 -4 -9] is sorted in descending order.<br />
All you need to do is <b>merge these sorted arrays</b> which is linear in time.<br />
<br />
So the algorithm is:<br />
<br />
Apply equation on each element<br />
Find maximum/minimum<br />
Merge subarrays<br />
<br />
Useful Link:<br />
<a href="http://stackoverflow.com/questions/4551599/sorting-result-array">http://stackoverflow.com/questions/4551599/sorting-result-array</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-28984387995866231902016-11-02T07:33:00.002-07:002016-11-02T07:33:50.859-07:00Own vesions of String library functions<div dir="ltr" style="text-align: left;" trbidi="on">
Write your own implementations for following string library functions<br />
<br />
1.strstr()<br />
2.strcpy()<br />
3.strcmp()<br />
4.substr()<br />
5.strdup()<br />
6.strlen()<br />
7.strcat()<br />
8.strchr()<br />
9.toUpper() & isUpper()<br />
<br />
Set-2<br />
1.strncmp()<br />
2.strncat()<br />
3.strncpy()<br />
4.strrchr()<br />
<br />
<div style="color: blue;">
<u><b>strcpy()</b></u></div>
Method 1:<br />
char *mystrcpy(char *dst, const char *src)<br />
{<br />
char *ptr;<br />
ptr = dst;<br />
while(*dst++=*src++);<br />
return(ptr);<br />
}<br />
Method 2:<br />
char *my_strcpy(char dest[], const char source[])<br />
{<br />
int i = 0;<br />
while (source[i] != '\0')<br />
{<br />
dest[i] = source[i];<br />
i++;<br />
}<br />
dest[i] = '\0';<br />
return(dest);<br />
}<br />
<b style="color: red;">NOTE:</b><br />
1.The strcpy function copies src, including the terminating null character, to the location specified by dst. <b>No overflow checking</b> is performed when strings are copied or appended. The behavior of strcpy is undefined if the source and destination strings overlap. It returns the destination string. No return value is reserved to indicate an error.<br />
<br />
2.Note that the prototype of strcpy as per the C standards is<br />
char *strcpy(char *dst, const char *src);<br />
Notice the const for the source, which signifies that the<b> function must not change the source string</b> in anyway!.<br />
<u style="color: blue;"><b>strncpy()</b></u><br />
<div id="I_description">
<pre>char * strncpy ( char * destination, const char * source, size_t num );</pre>
</div>
<div id="I_description">
<b>Copy characters from string</b></div>
Copies the first <i>num</i> characters of <i>source</i> to <i>destination</i>. If the end of the <i>source</i> C string (which is signaled by a null-character) is found before <i>num</i> characters have been copied, <i>destination</i> is padded with zeros until a total of <i>num</i> characters have been written to it.<br />
<br />
<b>No null-character is implicitly appended to the end of <i>destination</i>, so <i>destination</i> will only be null-terminated if the length of the C string in <i>source</i> is less than <i>num</i>.</b><br />
char *(strncpy)(char *s1, const char *s2, size_t n)<br />
{<br />
char *dst = s1;<br />
const char *src = s2;<br />
while (n > 0) {<br />
n--;<br />
if ((*dst++ = *src++) == '\0') {<br />
memset(dst, '\0', n);<br />
break;<br />
}<br />
}<br />
return s1;<br />
}<br />
<br />
<div style="color: blue;">
<u><b>substr():</b></u></div>
void mySubstr(char *dest, char *src, int position, int length)<br />
{<br />
while(length > 0)<br />
{<br />
*dest = *(src+position);<br />
dest++;<br />
src++;<br />
length--;<br />
}<br />
}<br />
Alternative:<br />
char *substr(const char *pstr, int start, int numchars)<br />
{<br />
char *pnew = (char *)malloc(numchars+1);<br />
strncpy(pnew, pstr + start, numchars);<br />
pnew[numchars] = '\0';<br />
return pnew;<br />
}<br />
<br />
Note:<br />
substr() is used to<b> copy a substring</b> starting from position upto length<br />
<br />
<div style="color: blue;">
<u><b>strdup():</b></u></div>
char *mystrdup(char *s)<br />
{<br />
char *result = (char*)malloc(strlen(s) + 1);<br />
if (result == (char*)0)<br />
{return (char*)0;}<br />
strcpy(result, s);<br />
return result;<br />
}<br />
<u style="color: blue;"><b>strcmp()</b></u><br />
<pre class="de1" style="font-family: inherit;"><span class="kw4">int</span> <span class="br0">(</span><span class="kw3">strcmp</span><span class="br0">)</span><span class="br0">(</span><span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span>s1<span class="sy0">,</span> <span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span>s2<span class="br0">)</span>
<span class="br0">{</span>
<span class="kw4">unsigned</span> <span class="kw4">char</span> uc1<span class="sy0">,</span> uc2<span class="sy0">;</span>
<span class="coMULTI">/* Move s1 and s2 to the first differing characters
in each string, or the ends of the strings if they
are identical. */</span>
<span class="kw1">while</span> <span class="br0">(</span><span class="sy0">*</span>s1 <span class="sy0">!=</span> <span class="st0">'<span class="es5">\0</span>'</span> <span class="sy0">&&</span> <span class="sy0">*</span>s1 <span class="sy0">==</span> <span class="sy0">*</span>s2<span class="br0">)</span> <span class="br0">{</span>
s1<span class="sy0">++;</span>
s2<span class="sy0">++;</span>
<span class="br0">}</span>
<span class="coMULTI">/* Compare the characters as unsigned char and
return the difference. */</span>
uc1 <span class="sy0">=</span> <span class="br0">(</span><span class="sy0">*</span><span class="br0">(</span><span class="kw4">unsigned</span> <span class="kw4">char</span> <span class="sy0">*</span><span class="br0">)</span> s1<span class="br0">)</span><span class="sy0">;</span>
uc2 <span class="sy0">=</span> <span class="br0">(</span><span class="sy0">*</span><span class="br0">(</span><span class="kw4">unsigned</span> <span class="kw4">char</span> <span class="sy0">*</span><span class="br0">)</span> s2<span class="br0">)</span><span class="sy0">;</span>
<span class="kw1">return</span> <span class="br0">(</span><span class="br0">(</span>uc1 <span class="sy0"><</span> uc2<span class="br0">)</span> <span class="sy0">?</span> <span class="sy0">-</span><span class="nu0">1</span> <span class="sy0">:</span> <span class="br0">(</span>uc1 <span class="sy0">></span> uc2<span class="br0">)</span><span class="br0">)</span><span class="sy0">;</span>
<span class="br0">}</span></pre>
<div style="color: red;">
<b>Note:</b></div>
strcmp(str1,str2) returns a -ve number if str1 is alphabetically less than str2, <b style="color: red;">0 if both are equal</b> and +ve if str1 is alphabetically above str2.The <b>prototype</b> of strcmp() is<br />
<br />
int strcmp( const char *string1, const char *string2 );<br />
<br />
<u style="color: blue;"><b>strncmp()</b></u><br />
int (strncmp)(const char *s1, const char *s2, size_t n)<br />
{<br />
unsigned char uc1, uc2;<br />
if (n == 0)<br />
return 0;<br />
while (n-- > 0 && *s1 == *s2)<br />
{<br />
if (n == 0 || *s1 == '\0')<br />
return 0;<br />
s1++;<br />
s2++;<br />
}<br />
uc1 = (*(unsigned char *) s1);<br />
uc2 = (*(unsigned char *) s2);<br />
return ((uc1 < uc2) ? -1 : (uc1 > uc2));<br />
}<br />
<div style="color: blue;">
<u><b>strlen():</b></u></div>
Method 1:<br />
int my_strlen(char *string)<br />
{<br />
int length;<br />
for (length = 0; *string != '\0', string++)<br />
{<br />
length++;<br />
}<br />
return(length);<br />
}<br />
Method 2: Pointer difference<br />
int my_strlen(char *s)<br />
{<br />
char *p=s;<br />
while(*p!='\0')<br />
p++;<br />
return(p-s);<br />
}<br />
Note:<br />
The prototype of the strlen() function is<br />
size_t strlen(const char *string);<br />
<br />
<pre class="de1"><u style="color: blue;"><b>strrchr()</b></u></pre>
<div class="prototype">
<pre>const char * strchr ( const char * str, int character );
char * strchr ( char * str, int character );</pre>
</div>
<b>Locate first occurrence of character in string</b><br />
Returns a pointer to the first occurrence of <i>character</i> in the C string <i>str</i>.<br />
The terminating null-character is considered part of the C string. Therefore, it can also be located to retrieve a pointer to the end of a string.<br />
<br />
<pre class="de1"><span class="kw4">char</span> <span class="sy0">*</span><span class="br0">(</span><span class="kw3">strrchr</span><span class="br0">)</span><span class="br0">(</span><span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span>s<span class="sy0">,</span> <span class="kw4">int</span> c<span class="br0">)</span>
<span class="br0">{</span>
<span class="kw4">const</span> <span class="kw4">char</span> <span class="sy0">*</span>last <span class="sy0">=</span> NULL<span class="sy0">;</span>
<span class="kw1">if</span> <span class="br0">(</span>c <span class="sy0">==</span> <span class="st0">'<span class="es5">\0</span>'</span><span class="br0">)</span>
<span class="kw1">return</span> <span class="kw3">strchr</span><span class="br0">(</span>s<span class="sy0">,</span> c<span class="br0">)</span><span class="sy0">;</span>
<span class="kw1">while</span> <span class="br0">(</span><span class="br0">(</span>s <span class="sy0">=</span> <span class="kw3">strchr</span><span class="br0">(</span>s<span class="sy0">,</span> c<span class="br0">)</span><span class="br0">)</span> <span class="sy0">!=</span> NULL<span class="br0">)</span> <span class="br0">{</span>
last <span class="sy0">=</span> s<span class="sy0">;</span>
s<span class="sy0">++;</span>
<span class="br0">}</span>
<span class="kw1">return</span> <span class="br0">(</span><span class="kw4">char</span> <span class="sy0">*</span><span class="br0">)</span> last<span class="sy0">;</span>
<span class="br0">}</span></pre>
<div style="color: blue;">
<u><b>strcat():</b></u></div>
char *myStrcat(char *s, const char *t)<br />
{<br />
char *p = s;<br />
if (s == NULL || t == NULL)<br />
return s; /* we need not have to do anything */<br />
while (*s)<br />
s++;<br />
while (*s++ = *t++);<br />
return p;<br />
}<br />
<u style="color: blue;"><b>strncat()</b></u><br />
<pre class="de1"><span style="font-size: small;"><span style="font-family: inherit;"> </span><span class="kw4" style="font-family: inherit;">char</span><span style="font-family: inherit;"> </span><span class="sy0" style="font-family: inherit;">*</span><span class="br0" style="font-family: inherit;">(</span><span class="kw3" style="font-family: inherit;">strncat</span><span class="br0" style="font-family: inherit;">)(</span><span class="kw4" style="font-family: inherit;">char</span><span style="font-family: inherit;"> </span><span class="sy0" style="font-family: inherit;">*</span><span style="font-family: inherit;">s1</span><span class="sy0" style="font-family: inherit;">,</span><span style="font-family: inherit;"> </span><span class="kw4" style="font-family: inherit;">const</span><span style="font-family: inherit;"> </span><span class="kw4" style="font-family: inherit;">char</span><span style="font-family: inherit;"> </span><span class="sy0" style="font-family: inherit;">*</span><span style="font-family: inherit;">s2</span><span class="sy0" style="font-family: inherit;">,</span><span style="font-family: inherit;"> </span><span class="kw4" style="font-family: inherit;">size_t</span><span style="font-family: inherit;"> n</span><span class="br0" style="font-family: inherit;">)</span>
<span style="font-family: inherit;"> </span><span class="br0" style="font-family: inherit;">{</span>
<span style="font-family: inherit;"> </span><span class="kw4" style="font-family: inherit;">char</span><span style="font-family: inherit;"> </span><span class="sy0" style="font-family: inherit;">*</span><span style="font-family: inherit;">s </span><span class="sy0" style="font-family: inherit;">=</span><span style="font-family: inherit;"> s1</span><span class="sy0" style="font-family: inherit;">;</span>
<span style="font-family: inherit;"> </span><span class="kw1" style="font-family: inherit;">while</span><span style="font-family: inherit;"> </span><span class="br0" style="font-family: inherit;">(</span><span class="sy0" style="font-family: inherit;">*</span><span style="font-family: inherit;">s </span><span class="sy0" style="font-family: inherit;">!=</span><span style="font-family: inherit;"> </span><span class="st0" style="font-family: inherit;">'<span class="es5">\0</span>'</span><span class="br0" style="font-family: inherit;">)</span>
<span style="font-family: inherit;"> s</span><span class="sy0" style="font-family: inherit;">++;</span>
<span style="font-family: inherit;"> </span><span class="kw1" style="font-family: inherit;">while</span><span style="font-family: inherit;"> </span><span class="br0" style="font-family: inherit;">(</span><span style="font-family: inherit;">n </span><span class="sy0" style="font-family: inherit;">!=</span><span style="font-family: inherit;"> </span><span class="nu0" style="font-family: inherit;">0</span><span style="font-family: inherit;"> </span><span class="sy0" style="font-family: inherit;">&&</span><span style="font-family: inherit;"> </span><span class="br0" style="font-family: inherit;">(</span><span class="sy0" style="font-family: inherit;">*</span><span style="font-family: inherit;">s </span><span class="sy0" style="font-family: inherit;">=</span><span style="font-family: inherit;"> </span><span class="sy0" style="font-family: inherit;">*</span><span style="font-family: inherit;">s2</span><span class="sy0" style="font-family: inherit;">++</span><span class="br0" style="font-family: inherit;">)</span><span style="font-family: inherit;"> </span><span class="sy0" style="font-family: inherit;">!=</span><span style="font-family: inherit;"> </span><span class="st0" style="font-family: inherit;">'<span class="es5">\0</span>'</span><span class="br0" style="font-family: inherit;">)</span><span style="font-family: inherit;"> </span><span class="br0" style="font-family: inherit;">{</span>
<span style="font-family: inherit;"> n</span><span class="sy0" style="font-family: inherit;">--;</span>
<span style="font-family: inherit;"> s</span><span class="sy0" style="font-family: inherit;">++;</span>
<span style="font-family: inherit;"> </span><span class="br0" style="font-family: inherit;">}</span>
<span style="font-family: inherit;"> </span><span class="kw1" style="font-family: inherit;">if</span><span style="font-family: inherit;"> </span><span class="br0" style="font-family: inherit;">(</span><span class="sy0" style="font-family: inherit;">*</span><span style="font-family: inherit;">s </span><span class="sy0" style="font-family: inherit;">!=</span><span style="font-family: inherit;"> </span><span class="st0" style="font-family: inherit;">'<span class="es5">\0</span>'</span><span class="br0" style="font-family: inherit;">)</span>
<span style="font-family: inherit;"> </span><span class="sy0" style="font-family: inherit;">*</span><span style="font-family: inherit;">s </span><span class="sy0" style="font-family: inherit;">=</span><span style="font-family: inherit;"> </span><span class="st0" style="font-family: inherit;">'<span class="es5">\0</span>'</span><span class="sy0" style="font-family: inherit;">;</span>
<span style="font-family: inherit;"> </span><span class="kw1" style="font-family: inherit;">return</span><span style="font-family: inherit;"> s1</span><span class="sy0" style="font-family: inherit;">;</span>
<span style="font-family: inherit;"> </span><span class="br0" style="font-family: inherit;">}</span></span></pre>
<br />
<u style="color: blue;"><b>toUpper():</b></u><br />
int toUpper(int ch)<br />
{<br />
if(ch>='a' && c<='z')<br />
return('A' + ch - 'a');<br />
else<br />
return(ch);<br />
}<br />
<br />
<u style="color: blue;"><b>isUpper():</b></u><br />
int isUpper(int ch)<br />
{<br />
if(ch>='A' && ch <='Z')<br />
return(1); //Yes, its upper!<br />
else<br />
return(0); // No, its lower!<br />
}<br />
Note:<br />
Another way to do this conversion is to maintain a correspondance between the upper and lower case alphabets. The program below does that. This frees us from the fact that these alphabets have a corresponding integer values.<br />
<br />
#include <string.h><br />
#define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"<br />
#define LOWER "abcdefghijklmnopqrstuvwxyz"<br />
<br />
int toUpper(int c)<br />
{<br />
const char *upper;<br />
const char *const lower = LOWER;<br />
<br />
// Get the position of the lower case alphabet in the LOWER string using the strchr() function ..<br />
upper = ( ((CHAR_MAX >= c)&&(c > '\0')) ? strchr(lower, c) : NULL);<br />
<br />
// Now return the corresponding alphabet at that position in the UPPER string ..<br />
return((upper != NULL)?UPPER[upper - lower] : c);<br />
}<br />
<br />
<span style="font-size: small;"><span class="br0" style="font-family: inherit;"></span></span>Useful Links:<br />
<a href="http://en.wikibooks.org/wiki/C_Programming/Strings">http://en.wikibooks.org/wiki/C_Programming/Strings</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-30814440974787518662016-10-16T04:52:00.003-07:002016-10-16T04:52:43.357-07:00Design Hit Counter<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #333333; font-family: "Open Sans"; font-size: 15px;"> If you are building a website, how do you count the number of visitors for the past 1 minute?</span><br />
<br />
<a href="http://blog.gainlo.co/index.php/2016/09/12/dropbox-interview-design-hit-counter/">http://blog.gainlo.co/index.php/2016/09/12/dropbox-interview-design-hit-counter/</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-18655711039960106612016-10-12T22:30:00.005-07:002016-11-12T00:23:53.464-08:00Group Shifted Strings<div dir="ltr" style="text-align: left;" trbidi="on">
Given an array of strings (all lowercase letters), the task is to group them in such a way that all strings in a group are shifted versions of each other. Two string S and T are called shifted if,<br />
<br />
S.length = T.length<br />
and<br />
S[i] = T[i] + K for<br />
1 <= i <= S.length for a constant integer K<br />
For example strings {acd, dfg, wyz, yab, mop} are shifted versions of each other.<br />
<a href="https://www.blogger.com/goog_1495440806"><br /></a>
<a href="http://www.geeksforgeeks.org/group-shifted-string/">http://www.geeksforgeeks.org/group-shifted-string/</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-2601709583800807042016-10-12T22:23:00.000-07:002016-11-12T00:23:53.468-08:00Count maximum points on same line<div dir="ltr" style="text-align: left;" trbidi="on">
Given N point on a 2D plane as pair of (x, y) co-ordinates, we need to find maximum number of point which lie on the same line.<br />
<br />
Examples:<br />
<br />
Input : points[] = {-1, 1}, {0, 0}, {1, 1},<br />
{2, 2}, {3, 3}, {3, 4}<br />
Output : 4<br />
Then maximum number of point which lie on same<br />
line are 4, those point are {0, 0}, {1, 1}, {2, 2},<br />
{3, 3}<br />
<br />
<a href="http://www.geeksforgeeks.org/count-maximum-points-on-same-line/">http://www.geeksforgeeks.org/count-maximum-points-on-same-line/</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-49021604825370333782016-10-12T10:26:00.001-07:002016-11-03T00:44:31.645-07:00Assembly Line Scheduling<div dir="ltr" style="text-align: left;" trbidi="on">
A car factory has two assembly lines, each with n stations. A station is denoted by Si,j where i is either 1 or 2 and indicates the assembly line the station is on, and j indicates the number of the station. The time taken per station is denoted by ai,j. Each station is dedicated to some sort of work like engine fitting, body fitting, painting and so on. So, a car chassis must pass through each of the n stations in order before exiting the factory. The parallel stations of the two assembly lines perform the same task. After it passes through station Si,j, it will continue to station Si,j+1 unless it decides to transfer to the other line. Continuing on the same line incurs no extra cost, but transferring from line i at station j – 1 to station j on the other line takes time ti,j. Each assembly line takes an entry time ei and exit time xi which may be different for the two lines. Give an algorithm for computing the minimum time it will take to build a car chassis.<br />
<br />
<a href="http://www.geeksforgeeks.org/dynamic-programming-set-34-assembly-line-scheduling/">http://www.geeksforgeeks.org/dynamic-programming-set-34-assembly-line-scheduling/</a><br />
<br />
<br /></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-67956566676878581652016-10-06T18:50:00.000-07:002016-10-06T18:50:43.266-07:00Happy Numbers<div dir="ltr" style="text-align: left;" trbidi="on">
What is an happy number can be shown in the following example:<br />
<br />
19 is a happy number<br />
1^2 + 9^2 = 82<br />
8^2 + 2^2 = 68<br />
6^2 + 8^2 = 100<br />
1^2 + 0^2 + 0^2 = 1<br />
<br />
<a href="http://www.programcreek.com/2014/04/leetcode-happy-number-java/">http://www.programcreek.com/2014/04/leetcode-happy-number-java/</a><br /><a href="http://getprogramcode.com/2013/12/java-program-to-check-for-a-happy-number/">http://getprogramcode.com/2013/12/java-program-to-check-for-a-happy-number/</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-57486020117950767892016-10-06T18:42:00.000-07:002016-10-06T18:42:36.905-07:00Caterpillars and Uneaten Leaves<div dir="ltr" style="text-align: left;" trbidi="on">
K caterpillars are eating their way through N leaves, each caterpillar falls from leaf to leaf in a unique sequence, all caterpillars start at a twig at position 0 and falls onto the leaves at position between 1 and N. Each caterpillar j has as associated jump number Aj. A caterpillar with jump number j eats leaves at positions that are multiple of j. It will proceed in the order j, 2j, 3j…. till it reaches the end of the leaves and it stops and build its cocoon.<br />
<br />
Given a set A of K elements K<-15, N<=10^9, we need to determine the number of uneaten leaves.<br />
<br />
Input:<br />
<br />
N= No of uneaten leaves.<br />
<br />
K= No. of caterpillars<br />
<br />
A = Array of integer jump numbers<br />
<br />
Output: The integer nu. Of uneaten leaves.<br />
<br />
Sample Input:10, 3, 2, 4, 5<br />
<br />
Output: 4<br />
<br />
Explanation:<br />
<br />
[2, 4, 5] is a j member jump numbers, all leaves which are multiple of 2, 4, and 5 are eaten, leaves 1,3,7,9 are left, and thus the no. 4<br />
<br />
<a href="http://codereview.stackexchange.com/questions/95145/caterpillar-uneaten-leaves">http://codereview.stackexchange.com/questions/95145/caterpillar-uneaten-leaves</a><br />
<a href="http://stackoverflow.com/questions/27248327/caterpillars-and-leaves-can-we-do-better-than-onc">http://stackoverflow.com/questions/27248327/caterpillars-and-leaves-can-we-do-better-than-onc</a><br />
<a href="http://qa.geeksforgeeks.org/219/uneaten-leaves-problem">http://qa.geeksforgeeks.org/219/uneaten-leaves-problem</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com1tag:blogger.com,1999:blog-207841116500949441.post-42681378201110027922016-09-27T12:43:00.000-07:002016-09-27T12:43:06.094-07:00Design a logging System<div dir="ltr" style="text-align: left;" trbidi="on">
<br /></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-17692878701678903452016-09-27T12:27:00.002-07:002016-09-27T12:27:39.076-07:00Design Redis<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://massivetechinterview.blogspot.in/2016/03/redis-architecture.html">http://massivetechinterview.blogspot.in/2016/03/redis-architecture.html</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-5706495070700787962016-09-27T12:18:00.000-07:002016-09-27T12:18:00.264-07:00Design Google Maps, Calender, Big Table, File System, Spanner<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://massivetechinterview.blogspot.in/2015/10/google-file-system.html">http://massivetechinterview.blogspot.in/2015/10/google-file-system.html</a><br />
<a href="http://massivetechinterview.blogspot.in/2015/10/google-map-architecture.html">http://massivetechinterview.blogspot.in/2015/10/google-map-architecture.html</a><br />
<a href="http://massivetechinterview.blogspot.in/2015/10/google-calendar-architecture.html">http://massivetechinterview.blogspot.in/2015/10/google-calendar-architecture.html</a><br />
<a href="http://massivetechinterview.blogspot.in/2015/10/google-bigtable-architecture.html">http://massivetechinterview.blogspot.in/2015/10/google-bigtable-architecture.html</a><br />
<a href="http://massivetechinterview.blogspot.in/2015/10/google-spanner-architecture.html">http://massivetechinterview.blogspot.in/2015/10/google-spanner-architecture.html</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-51497836496740676302016-09-27T12:04:00.000-07:002016-10-31T11:26:44.274-07:00Pending<div dir="ltr" style="text-align: left;" trbidi="on">
<br /></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-91764380967609036092016-09-27T11:46:00.003-07:002016-09-27T11:46:15.230-07:00Design a generic automated test suite<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
<span style="color: #333333; font-family: Georgia, Times, Times New Roman, serif;"><span style="font-size: 15px;">Design a generic automated test suite.</span></span></div>
</div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-73667984826297506632016-09-14T12:25:00.004-07:002016-09-14T12:25:23.890-07:00Active and Inactive cells after k Days<div dir="ltr" style="text-align: left;" trbidi="on">
Given a binary array of size n where n > 3. A true (or 1) value in the array means active and false (or 0) means inactive. Given a number k, the task is to find count of active and inactive cells after k days. After every day, status of i’th cell becomes inactive if its left and right cells have same value, i.e., either both are 0 or both are 1.<br />
Since there are no cells before leftmost and after rightmost cells, the value cells before leftmost and after rightmost cells is always considered as 0 (or inactive).<br />
<br />
<a href="http://www.geeksforgeeks.org/active-inactive-cells-k-days/">http://www.geeksforgeeks.org/active-inactive-cells-k-days/</a></div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-29709505913524459992016-09-14T12:17:00.001-07:002016-09-14T12:17:30.403-07:00Maximize value of (arr[i] – i) – (arr[j] – j) in an array<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
Given an array, arr[] find the maximum value of (arr[i] – i) – (arr[j] – j) where i is not equal to j. Where i and j vary from 0 to n-1 and n is size of input array arr[].</div>
<div>
<br /></div>
<div>
<a href="http://www.geeksforgeeks.org/maximize-value-of-arri-i-arrj-j-in-an-array/">http://www.geeksforgeeks.org/maximize-value-of-arri-i-arrj-j-in-an-array/</a></div>
</div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0tag:blogger.com,1999:blog-207841116500949441.post-43602849356712471822016-09-13T04:09:00.002-07:002016-10-31T11:10:41.429-07:00Behavioural Questions<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: "open sans" , "helvetica" , "arial" , "verdana" , sans-serif; font-size: 13px; line-height: 22.2857px; text-align: justify;">Behavioral Questions</span><br />
<ol style="background-color: white; border: 0px; font-family: "Open Sans", Helvetica, Arial, Verdana, sans-serif; font-size: 13px; line-height: 22.2857px; list-style-position: outside; margin: 0px; padding: 0px; text-align: justify; vertical-align: baseline;">
<li style="border: 0px; margin: 0px 0px 0px 36px; padding: 0px; vertical-align: baseline;">Things u learn in 3 years of experience which makes u different from fresher guy?</li>
<li style="border: 0px; margin: 0px 0px 0px 36px; padding: 0px; vertical-align: baseline;">Project description</li>
<li style="border: 0px; margin: 0px 0px 0px 36px; padding: 0px; vertical-align: baseline;">Discussion about my project details and challenging task</li>
</ol>
</div>
Sudhttp://www.blogger.com/profile/10580179154292990042noreply@blogger.com0