annu025
BAN USER
- 2of 2 votes
AnswerEvaluate infix expression: 2 + 3 * 5
- annu025 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer - 0of 0 votes
AnswerWrite a word processor that can do left and right justification for a sample input of string type.
- annu025 in United States
Here is an example:
This is a sample.This is a sample.This is a sample.
This is a sample.This is a sample.This is a sample.This is a sample.
Additional details:
* The left margin is 5 units.
* The right margin is 75 units.
* The input string is a single-spaced collection of words and punctuation.
* If the length of the word exceeds the right margin, then we must not break the word. Instead, we must print it on the next line and justify the existing line by adding more spaces to the middle of the line.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer String Manipulation - 2of 2 votes
AnswersReverse this string 1+2*3-20. Note: 20 must be retained as is.
- annu025 in United States
Expected output: 20-3*2+1| Report Duplicate | Flag | PURGE
String Manipulation - 0of 0 votes
AnswersYou are tasked with defining and implementing a function. as input, you are given an n x m matrix. x may appear any number of times in a matrix. your function should modify thebmatrix such that any row and column where x originally appears are completely over written with x
- annu025 in United States
For example:
- - - - -
- - - - -
- - - x -
x - - - -
- - - - -
Expected output:
x - - x -
x - - x -
x x x x x
x x x x x
x - - x -| Report Duplicate | Flag | PURGE
Software Engineer / Developer Matrix
Solution in Java:
public class FindElementInSortedRotatedArray {
private static int findElement(int [] input, int target){
if(input == null || input.length == 0){
return -1;
}
int start = 0;
int end = input.length - 1;
int mid = (start + end)/2;
for(int i = 0; i < input.length; i++){
// check if start to mid of input array is sorted
if(input[start] <= input[mid]){
// check if target element lies between start and mid
if(input[start] <= target && target <= input[mid]){
// if target lies with start and mid, set end pointer to mid-1
end = mid - 1;
}
else{
start = mid + 1;
}
}
// then check if mid to end of input array is sorted
else {
if(input[mid] <= target && target <= input[end]){
// set start pointer to mid + 1
start = mid + 1;
}
else {
end = mid - 1;
}
}
}
return -1;
}
public static void main(String[] args) {
{
int array[] = { 56, 58, 67, 76, 21, 32, 37, 40, 45, 49 };
findElementUsingBinarySearchTest(array, 45);
}
}
private static void findElementUsingBinarySearchTest(int[] array, int num) {
System.out.println("Element " + num + " found at = " + findElement(array, num));
}
}
My solution in Java:
import java.util.Random;
public class ShuffleDeckOfCards {
private static void shuffle(int[] input) {
int inputLength = input.length;
// class to generate random numbers
Random r = new Random();
for (int i = inputLength - 1; i > 0; i--) {
// Generate random index
int index = r.nextInt(i);
// swap i with randomly generated index
int temp = input[index];
input[index] = input[i];
input[i] = temp;
}
}
public static void main(String[] args) {
int[] cards = new int[52];
for (int i = 0; i < 52; i++) {
cards[i] = i + 1;
}
shuffle(cards);
}
}
// Time complexity: O(N)
public class Attempt1{
boolean[] row = new boolean[n];
boolean[] column = new boolean[n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (matrix[i][j] == "x") {
row[i] = true;
column[j] = true;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (row[i] || column[j]) {
matrix[i][j] = "x";
}
}
}
System.out.println("Resultant matrix: ");
printMatrix(matrix, n);
return matrix;
}
Here are my questions: 1. Is there a better way to solve this? 2. Should I consider a better data structure?
Thank you.
Repfrancesdpayne, AT&T Customer service email at Cavium Networks
I am Frances Payne from Jacksonville, United States. I am working as a Rental manager in Magna Gases company. I ...
Repnoradweisser, Backend Developer at ASU
I am Nora, I am a writer, I write many types blogs and articles. I collected many types and astrology ...
Repvickiwgerber, Member Technical Staff at Boomerang Commerce
I am Vicki From San Antonio USA, I am working as an Interior decorator in Golden Joy company. I have ...
Repchingdelisa, Accountant at ABC TECH SUPPORT
I'm a Creative director in San Diego, USA.I map out future plans and make sure the result and ...
Repjenniferdray9, Accountant at ABC TECH SUPPORT
Hi I am Jennifer D. Ray from san Diego.Currently i am working as a parts salesperson in Rite solution ...
Repkellydbrown23, Jr. Software Engineer at Auto NInja
I live in College Park USA with my family, and my current job is clerk in Luria’s company. I ...
Repannaharricks, Computer Scientist at ABC TECH SUPPORT
Hi, I am a Social worker to help people handle everyday life problems. I also assist people who have issues ...
Repjosephcday6, Android Engineer at Absolute Softech Ltd
I am SEO Executive in Elek-Tek company. I live in Morgantown USA. I won’t write any details about Best ...
Repcarlaapepin, Area Sales Manager at Atmel
Hello, I am Carla and I live in San Bernardino, USA. I am working as a bookkeeper in a library ...
RepPriscillaRYoung, Aghori Mahakal Tantrik at Absolute Softech Ltd
Hi, I am Priscilla from California. I am working as a Business management consultant in Quality Merchant Services company. I ...
Reprachelwrosa1, Computer Scientist at ABC TECH SUPPORT
Hello, I am Rachel and I live in Charleston, USA. I am working as a data entry clerk who is ...
Repmarywwaldrop7, Computer Scientist at Chelsio Communications
I am Mary ,working in the field of training and development coordinator for three years, focusing on teaching English as ...
Repvictorcraigw, Animator at Chicago Mercantile Exchange
Hi, I am Victor working as a Speech Writer in the USA. Spoke at an academic conference about mantra for ...
Open Chat in New Window
Sample input:
- annu025 March 07, 2018This is a sample.This is a sample.This is a sample.This is a sample.
This is a sample.This is a sample.This is a sample.This is a sample. This
is a sample.This is a sample.This is a sample.This is a sample.This is a
sample.