Forum Posts
- 1 Answer Code from the book (ctci) uses '==' operator instead of equals
Just a FYI, some of the Java code may not work properly. There are several cases the == operator instead of equals. E.g. in 16.5 and Question 4.2 are some off the top of my head.
- berlin.brown February 03, 2013
Also,
public void run() {
if (method == "first") {
foo.first();
} else if (method == "second") {
foo.second();
} else if (method == "third") {
foo.third();
}
}| Flag | PURGE - 0 Answers C
Write a code to extract individual blocks from a given matrix....
- Honey February 02, 2013
Eg: if we have a 4x4 matrix you need to extract 2x2 independent matrices and store them in 4 different arrays...
Given matrix: 1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
For the above matrix the output should be as follows..
Array1: 1 2 5 6
Array2: 3 4 7 8
Array3: 9 10 13 14
Array4: 11 12 15 16| Flag | PURGE - 0 Answers Data Structures
A spreadsheet consists of a two-dimensional array of cells, labeled A1, A2, etc. Rows are
- sandeep17199117 February 01, 2013
identified using letters, columns by numbers. Each cell contains either an integer (its value) or
an expression. Expressions contain integers, cell references, and the operators '+', '-', '*', '/'
with the usual rules of evaluation – note that the input is RPN and should be evaluated in stack
order.
Write a program (in C, C++ or Java) to read a spreadsheet from ‘stdin’, evaluate the values of
all the cells, and write the output to ‘stdout’.
The spreadsheet input is defined as follows:
• Line 1: two integers, defining the width and height of the spreadsheet (n, m)
• n*m lines each containing an expression which is the value of the corresponding cell
(cells enumerated in the order A1, A2, A<n>, B1, ...)
Your program must output its data in the same format, but each cell should be reduced to a
single floating-point value. For example, we would expect the following expect to produce the
indicated output:
Input Expected Output
3 2
A2
4 5 *
A1
A1 B2 / 2 +
3
39 B1 B2 * /
3 2
20.00000
20.00000
20.00000
8.66667
3.00000
1.50000
The above example input visually looks like:
| 1 | 2 | 3 |
--+-------------+-------+--------------+
A | A2 | 4 5 * | A1 |
--+-------------+-------+--------------+
B | A1 B2 / 2 + | 3 | 39 B1 B2 * / |
------------------------+--------------+| Flag | PURGE - 1 Answer Convert a rectangle to ranges of Hilbert numbers
When spatial data is represented using Hilbert numbers, a rectangular range is mapped to multiple ranges of Hilbert numbers. Is there any quick way to find this mapping without going through every cell the given rectangle, R, overlaps with? I can think of considering only the border cells of R and then sorting them... Is there any better way?
- iamru January 31, 2013| Flag | PURGE - 1 Answer Question about rating your skills
So I have seen a couple of posts that say you shouldn't rate yourself too high in one particular area. You shouldn't rate yourself too low in one particular area. Let's say I have been working Java 8 years (pretty much everyday), I am pretty fluent in Java. I would probably rate myself a 8/10. There are still some things on JVM memory and heap analysis and garbage collection that I don't entirely understand so I would say 8/10.
- berlin.brown January 31, 2013
I have done Python for scripts off and on for years but I may have trouble with throwing ou the syntax without googling it. What is that? 7/10? 6/10? And then on C/C++. I have coded with them off and on years ago, 5/10?
I am sure we have all worked with various languages how do we approach them in a Google/Amazon like interview. Am I OK with just Java as 8/10. I will have to mention python and C/C++ because it was part of my job but I am not as fluent. And then there is Haskell, Scala, Clojure which I have been working with also off and on for practice.
What do you think? How would a google interviewer approach these ratings?
Java : 8/10 (fluent but still some things I could learn).
Python : 7/10? (I don't work with python every day, I only work with small scripts for automating simple tasks). I may not be able to come up with the syntax entirely in an interview (E.g. I would have to google it).
C/C++ : 6/10 - I was fluent years ago?
Scala/Clojure : 3/10?| Flag | PURGE - 0 Answers Big‐theta complexity class: Trouble determining class + # operations from code:
I have finished some code, which works as I would like it to. I'm not looking to change for better optimization (right now).
However, I have trouble with determining Big-theta complexity classes in code, even if it's not my own. I was hoping someone could help explain an easy way to determine Big-theta complexity classes and show that it's true through general equations.
Here's my sample code: (determine Big-theta complexity class for longestRun and evenSplitPoint)
- Reno.and.Rude January 31, 2013import java.util.*; /** * Contains two methods for manipulating integer sequences in an array. * * @author Jonathan Jenkins * @version 1.0 * */ public class Algorithms1 { /** * Returns the value that appears in the longest run of consecutive values. * * @param list array containing int values to be processed * @return the value that appears in the longest "run" of consecutive values * */ public static int longestRun (int[] list) { /** @param num Initializing the first element of the array @param current Counting the first entry of the value count in the sequence to 1 @param max Initialize max to 1; keeps the max sequence @param value Will hold the value of the element that has the longest sequence and return it */ int num = list[0]; int current = 1; int max = 1; int value = 0; /** Traverse the array */ for (int i = 1; i < list.length; i++) { /** If the next element in the array is the same as the last element, incrase the current sequence by 1 */ if (list[i] == num) { current++; } /** Reset the current sequence to 1 since the next element in the array is not the same as the last */ else { current = 1; } /** If current sequence is greater than a previously max sequence, make the current sequence the new max sequence and store that element in value */ if (current > max) { max = current; value = list[i]; } /** Loads the next element of the array to be compared to the last */ num = list[i]; } /** @return Returns the element of the array that had the longest sequential sequence */ return value; } /** * * Returns the index of the value that would logically partition the array * into two sections, such that the sum of the values in each section is as * close to the other one as possible. * * @param list array containing int values to be processed * @return an index k, such that the sum of values 0..k and k+1..n-1 are as close as possible * */ public static int evenSplitPoint (int[] list) { /** @param total Initialize total */ int total = 0; /** For loop to compute the total of the entire array */ for (int i = 0; i < list.length; i++) { total += list[i]; } /** @param min The storage value for the smallest difference in left and right arrays; set to largest value in beginning @param equilibrium Initialize to store the index of the split point @param left The total value of the left side of the array @param right Currently the total of the array, later to be the total of the right side of the array */ int min = Integer.MAX_VALUE; int equilibrium = 0; int left = 0; int right = total; /** Traverse array */ for (int i = 0; i < list.length; i++) { /** Getting the sum of the left side of the array by adding elements to an empty total (0) */ left += list[i]; /** Gett the sum of the right side of the array by removing elements from a total sum */ right -= list[i]; /** Calculating the difference in the left and right arrays */ int diff = Math.abs(left - right); /** When the difference in the left and right arrays is less than the vaule stored in 'min', the equilibrium will be set to the current index and the difference will be the new 'min' */ if (diff < min) { equilibrium = i; min = diff; } } /** @return Returns the index at which the difference between the left and right arrays was the smallest */ return equilibrium; } public static void main(String[] args) { int[] a1 = {0, 2, 8, 8, 4, 4, 4, 8}; int[] a2 = {0, 0, 0, 0, 3, 3, 3, 8, 14, 21, 3, 3, 3}; System.out.println(longestRun(a1)); // 4 expected System.out.println(longestRun(a2)); // 0 expected System.out.println(evenSplitPoint(a1)); // 3 expected System.out.println(evenSplitPoint(a2)); // 8 expected } }
| Flag | PURGE - 1 Answer High School Senior Network Engineering Internships?
These companies do not specify clearly on their websites whether or not high schools seniors are eligible for their summer internships. So, my question clearly is would they even consider my application. Specifically Google.
- trblandford4 January 31, 2013
My achievements are:
-Cisco Certified (currently CCENT, CCNA to be taken next month) (enrolled in Cisco Academy)
- intern with local IT company
- 4.0 GPA senior year
- Captain of Lacrosse Team and Eagle Scout (leadership ability)
- over 150 hours of community service in high school
I won't list my entire resume, but I'd say for a Network Engineering internship I think I am qualified. Criticism is MUCH appreciated.| Flag | PURGE - 1 Answer Amazon Online Test
Given 2D int array a x a. Rotate it 90 deg. in anti-clockwise manner. Also given an int x (last input) which is to be added to every integer at nth column where n is a prime no. Consider 1 as non-prime
- vish January 28, 2013
Example:
Input
1 2 3
4 5 6
7 8 9
1
Output:
3 7 10
2 6 9
1 5 8
Explanation:
Anti-clockwise rotation
3 6 9
2 5 8
1 4 7
and then add 1 (which is input x) to every integer at 2nd and 3rd column (since 2 and 3 are prime no.)| Flag | PURGE - 10 Answers How much should I quote my salary expectations for Amazon India?
Hello everyone,
- Pallani S January 28, 2013
I recently got an offer from Amazon India. I have three years of experience. They have confirmed my selection but didn't give the offer yet. They asked me for my salary expectations and I said "Company Standards". The HR told me that the offer will be good itself.
I wanted to know is this a mistake I did? Should I have quoted a figure to them? I thought I will do the negotiations once I get the offer in hand. Also, how much time typically Amazon takes to give the offer letter once they confirm the selection? Any other inputs or suggestions is highly appreciated.
Thanks| Flag | PURGE - 1 Answer Check if a tree is balanced. Why should we check MinDepth? Please help me.
Solution found in CareerCup
- sivaji8 January 18, 2013
public static int maxDepth(TreeNode root) {
if (root == null) {
return 0;
}
return 1 + Math.max(maxDepth(root.left), maxDepth(root.right));
}
public static int minDepth(TreeNode root) {
if (root == null) {
return 0;
}
return 1 + Math.min(minDepth(root.left), minDepth(root.right));
}
public static boolean isBalanced(TreeNode root){
return (maxDepth(root) - minDepth(root) <= 1);
}
Why not the following solution work?? Please explain in detail
public static int maxDepth(TreeNode root){
if(root==null)
return 0;
return 1+ Math.max(maxDepth(root.left), maxDepth(root.right));
}
public static boolean isBalanced(TreeNode root){
return (maxDepth(root.left) - maxDepth(root.right) <=1);
}| Flag | PURGE - 2 Answers Amazon interview
How long will amazon take to reply ??? i gave it 1 week back
- PRAJWALPRAS January 16, 2013| Flag | PURGE - 1 Answer What is the output of this SQL query?
I 've table book containg 2 columns
- accessdenied January 14, 2013
title and price
there are a number of books there with different prices
what is result of the following query
select title from book as b where (select count(*) from book as t where t.price>b.price) < 5| Flag | PURGE - 6 Answers this is my general doubt not a...
this is my general doubt not a particular question .
- zeroByzero January 06, 2013
1. how should we respond if we have no clue about the problem asked ..?
2. and are we asked to code all problems they ask.., like if problem involve complex data structure if you know the approach to the problem ,do they also ask for their code ,.?| Flag | PURGE - 0 Answers Find the highest number after rearranging digits
Do it in O(n) time
- popoff January 01, 2013| Flag | PURGE - 0 Answers pls give me ans
code to cmp two strings in two diffrnt text file.... in c....
- bsreddy91 December 29, 2012| Flag | PURGE