Knoa Software Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

void reverse(char *x)
{
    int len = strlen(x); // for speed only
    for (int c=0; c<len/2; c++){
        x[len-c-1] ^= x[c];
        x[c] ^= x[len-c-1];
        x[len-c-1] ^= x[c];
    }
}

- strezh September 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

excellent solution xor 3 times


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
String s = "vijay";
String s1=reverse(s);
Console.WriteLine(s1);
Console.Read();
}

static String reverse(string str)
{

char[] charArray = str.ToCharArray();
int length = str.Length - 1;

for (int i = 0; i < length; i++, length--)
{

charArray[i] ^= charArray[length];
charArray[length] ^= charArray[i];
charArray[i] ^= charArray[length];
}
return new string(charArray);
}
}
}

- vvg September 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

thanks a lot for this concept didn't strike at the first place....awesome solution.

- Anonymous August 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here is the Java code:
class reveseString{
public static void main(String args[])
{
String st = "yourString"; //Here you can replace yourString with some String
StringBuffer sbf = new StringBuffer(st);
int start=0,end=st.length()-1;
while(start<end)
{
sbf.setCharAt(start,(char)(sbf.charAt(start)^sbf.charAt(end)));
sbf.setCharAt(end,(char)(sbf.charAt(end)^sbf.charAt(start)));
sbf.setCharAt(start,(char)(sbf.charAt(start)^sbf.charAt(end)));
start++;
end--;
}
System.out.println(sbf);
}
}

- Ravi Ranjan March 08, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int len = strlen(x); // for speed only
for (int c=0; c<len/2; c++){
x[len-c-1] ^= x[c];
x[c] ^= x[len-c-1];
x[len-c-1] ^= x[c];
}

- Anonymous April 24, 2020 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More