GE (General Electric) Interview Question for Software Developers


Country: United States
Interview Type: In-Person




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

reverse(String str){
if(str.length()==1)
return str;
return str.charAt(str.length()-1) + reverse(str.substring(0, str.length()-2));

}

- Logan August 01, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class StringRotate {

public static void main(String[] args) {
String str="General Electric";
StringBuffer sb = new StringBuffer();
for(String s: str.split(" ")){
sb.append(shift(s,3));
sb.append(" ");
}
System.out.println(sb.toString());
}

public static String shift(final String input, final int shift){
if(input==null || input.length()==0){
return "";
}
int length = input.length();
int offSet = shift % length;
return input.substring(offSet,length)+input.substring(0,offSet);
}
}

- lparka123 July 25, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if(str2.length()==1) {
return str2;
}else {
return str2.charAt(str2.length()-1)+reverse(str2.substring(0, str2.length()-1));

}
}

- sadhana September 29, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

if(str2.length()==1) {
			return str2;
			}else {
				return str2.charAt(str2.length()-1)+reverse(str2.substring(0, str2.length()-1));
			
		}

}

- Sadhana September 29, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def rightShift(str_var,rightS):
    lst = list(str_var)
    for i in range(rightS):
       lst.insert(0,lst.pop())     
    str_right = ''.join(str(e) for e in lst)
    print str_right
    
def leftShift(str_var,leftS):
    lst = list(str_var)
    for i in range(leftS):        
       lst.insert(len(lst) - 1,lst.pop(0)) 
    str_left = ''.join(str(e) for e in lst)
    print str_left 

str_var = "rightshift"
print str_var
rightShift(str_var,2)
leftShift(str_var,2)

- RakeshSharma November 03, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def right_shift(string):
    return string[-3::] + string[0:-3]


def left_shift(string):
    return string[3::] + string[0:3]


print(right_shift("HelloWorld"))
print(left_shift("HelloWorld"))

- Enthrayu January 27, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Python

def takeinput():
	s = raw_input ("Please Enter the String :")
	n = input ("Please enter 'n' :" )
	n = int(n)
	
	len1 = len(s)
	if len1 <= n:
		print "Shifts cannot be performed on this string!!"


	s1 = leftshift(s,n)
	s2 = rightshift(s,n)

	return s1,s2


def leftshift(s,n):
	len1 = len(s)
	s1 = ''
	for i in range(n,len1):
		s1 = s1+s[i]

	for i in range(0,n):
		s1 = s1+s[i]

	return s1

def rightshift(s,n):
	len1 = len(s)
	s2 = ''
	for i in range (len1-n, len1):
		s2 = s2 + s[i]
	
	for i in range (0, len1-n) :
		s2 = s2+s[i]

	return s2



s1,s2 = takeinput()
print ("Left Shift on String is %s :" , s1)
print ("Right Shift on String is %s :", s2)

- koolkhush February 08, 2018 | 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