Search Results

Search found 1507 results on 61 pages for 'interview'.

Page 28/61 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • test cases for testing a strtok-alike function [C++]

    - by Neeraj
    Consider the following class definition: class StrToTokens { StrToTokens(const char* str, const char* delimiters = "\t\r\n"); //constructor string getNextToken(); void reset(); bool empty(); } Can someone list some good testcases to test the above class. A few I could think of are: empty string, empty delimiters, repeated delimiters, consecutive delimiters, string with only delimiters. However, the interviewer expected some more(better ones). Can you help out. Thanks.

    Read the article

  • How many programming jobs are there that require German/French language ?

    - by HJ-INCPP
    Hello, I want to improve my chances getting a job (entry-level:programming) by learning another language. How many jobs that require exclusively French, German, English are there ? Which is better to learn (more/better jobs): French or German ? Is it worth it (or should I learn another programming language instead :D) ? Thank you. P.S I live in Romania, I (think I) know English

    Read the article

  • find a duplicate entry in an array in constant space and O(n) time [closed]

    - by Anubhav Agarwal
    Possible Duplicate: Algorithm to find a duplicate entry in constant space and O(n) time Given an array of N integer such that only one integer is repeated. Find the repeated integer in O(n) time and constant space. There is no range for the value of integers or the value of N For example given an array of 6 integers as 23 45 67 87 23 47. The answer is 23 (I hope this covers ambiguous and vague part) I searched on the net but was unable to find any such question in which range of integers was not fixed. Also here is an example that answers a similar question to mine but here he created a hash table with the highest integer value in C++.But the cpp does not allow such to create an array with 2^64 element(on a 64-bit computer).

    Read the article

  • Puzzle: find the minimum number of weights

    - by avd
    I came across this question: say given two weights 1 and 3, u can weigh 1,2 (by 3-1),3,4 (by 3+1). Now find the minimum number of weights so that you can measure 1 to 1000. So the answer was 1,3,9,27... I want to know how do you arrive at such a solution means powers of 3. What is the thought process? Source: http://classic-puzzles.blogspot.com/search/label/Google%20Interview%20Puzzles Solution: http://classic-puzzles.blogspot.com/2006/12/solution-to-shopkeeper-problem.html

    Read the article

  • One-way flight trip problem.

    - by psihodelia
    You are going on a one-way indirect flight trip that includes billions transfers. You are not stopping twice in the same airport. You have 1 ticket for each part of your trip. Each ticket contains src and dst airport. All the tickets you have are randomly sorted. You forgot the original departure airport (very first src) and your destination (last dst). Design an algorithm to reconstruct your trip with minimum big-O complexity.

    Read the article

  • Bug in Programming Interviews Exposed?

    - by Sam
    Hi, I could not find an errata for the 2nd edition of this book. My question concerns the if-statement in the following piece of code. void removeHead (Node ** head) { Node * temp; if (!(*head)) { temp = (*head)->next; delete *head; *head = temp; } } So I understand that the point of the if-statement is to check if the Node is null. However by adding an additional "!" to the evaluation, wouldn't this negate the false value of null? Would it be correct to change it to something like: if (*head) { ... } Also if anyone knows where I can find an official errata for the 2nd edition that would be great. Thanks, Sam

    Read the article

  • How to compute palindrome from a stream of characters in sub-linear space/time?

    - by wrick
    I don't even know if a solution exists or not. Here is the problem in detail. You are a program that is accepting an infinitely long stream of characters (for simplicity you can assume characters are either 1 or 0). At any point, I can stop the stream (let's say after N characters were passed through) and ask you if the string received so far is a palindrome or not. How can you do this using less sub-linear space and/or time.

    Read the article

  • How to find validity of a string of parentheses, curly brackets and square brackets?

    - by Rajendra
    I recently came in contact with this interesting problem. You are given a string containing just the characters '(', ')', '{', '}', '[' and ']', for example, "[{()}]", you need to write a function which will check validity of such an input string, function may be like this: bool isValid(char* s); these brackets have to close in the correct order, for example "()" and "()[]{}" are all valid but "(]", "([)]" and "{{{{" are not! I came out with following O(n) time and O(n) space complexity solution, which works fine: Maintain a stack of characters. Whenever you find opening braces '(', '{' OR '[' push it on the stack. Whenever you find closing braces ')', '}' OR ']' , check if top of stack is corresponding opening bracket, if yes, then pop the stack, else break the loop and return false. Repeat steps 2 - 3 until end of the string. This works, but can we optimize it for space, may be constant extra space, I understand that time complexity cannot be less than O(n) as we have to look at every character. So my question is can we solve this problem in O(1) space?

    Read the article

  • Can a pointer ever point to itself?

    - by eSKay
    This question was mentioned here. My doubt is: If a pointer variable has the same address as its value, is it really pointing to itself? For example - in the following piece of code, is a a pointer to itself? #include<stdio.h> int main(){ int* a; int b = (int)&a; a = b; printf("address of a = %d\n", &a); printf(" value of a = %d\n", a); } If a is not a pointer to itself, then the same question poses again: Can a pointer point to itself? Also, how is a self pointing pointer useful?

    Read the article

  • How to find the closest descendants (that matches a selector) with jQuery?

    - by powerboy
    We can use closest(selector) to find the first ancestor element that matches the selector. It travels up the DOM tree until it finds a match for the selector. But what if I want to travels down the DOM tree until it finds a match for the selector? Is there any jQuery function for doing this? Or do I need to implement this using breadth-first search? Give an example. For the DOM tree below, <div id="main"> <div> <ul><!-- I want to match this ul --> <li> <ul><!-- but not this ul --> </ul> </li> </ul> <ul><!-- and match this ul --> </ul> </div> </div> how to do something like $('#main').closestDescendants('ul')?

    Read the article

  • where can I get these kind of exercises to solve?

    - by flash
    Recently I did a Java programming exercise successfully which was sent by a recruiting firm, The problem statement goes like this 'There are two text files FI(records abt files and directory information) and FS(containing blocks of data) which represent a file Index and file System respectively and I was supposed to write a static read method in a class which will read the file from the FS depending upon the path string provided using FI' My question is where can I get these kind of exercises to solve, the complexity should be above average to tough.

    Read the article

  • What does an object file contain

    - by benjamin button
    HI everyone, during the various stages of compilation in C or C++, i know that an object file gets generated. i.e., any_name.o file. what does thos .o file contain actually. i cant open it since its a binary file. Could anybody please help me? are the contents of the object file mainly Dependant on the compiler which we use on unix?

    Read the article

  • Crash the program with cmd line args

    - by Debanjan
    Lets us consider the following program : #include <stdlib.h> int main(int argc, char **argv){ int a,b; if (argc != 3) return -1; a = atoi(argv[1]); b = atoi(argv[2]); a = b ? a/b : 0; return a; } The task is to crash the program by providing arguments in command-line.

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >