Weed Out Questions Flashcards

1
Q

Find Second Highest Salary (SQL)

A

SELECT MAX(Salary) From Employee where Salary Not In (SELECT MAX(Salary From Employee

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Difference between GET and POST (HTTP)

A

GET retrieves data from the server and POST creates/updates. POST is different that PUT in that calling POST multiple times creates multiple instances of same data. GET is in URL, POST is in HTML Forms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Difference between a Class and an object

A

Class defines the structure, methods, initial values etc. and an object is an instance of a class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

FizzBuzz

A

1-100, multiples of 3: “Fizz”, multiples of 5: “Buzz”, multiples of 3 and 5 “FizzBuzz”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Fibonocci Sequence in different optimization iterations

A

Brute force, Recursion, Dynamic Programming, Store last two numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Add, Remove, Insert elements from a LinkedList

A

<code></code>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Find the middle element of a linked list in one pass

A

Maintain two pointers with one increment by two and the other by one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Find the kth element in one pass

A

Two pointers, when one reaches the kth element, start the other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In an integer array 1 to 100 find the duplicate number

A

Total sum should be equal to n(n+1)/2 so simply subtract actual sum from expected sum

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Reverse a string

A

<code></code>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Sort an array with bubble sort

A

<code></code>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Difference between stack and queue

A

LIFO, FIFO

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Find duplicates in an array if there are more than one duplicate

A

Store each element in a hashmap as a key with the number of occurrences as a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Difference between singly and doubly linked list

A

Singly linked has one pointer to the next node, doubly has two pointers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Check if a number is a palindrome

A

For reference: 1234/10 will give you 123 and 1234%10 will return 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a binary search tree

A

Left node has values less than root right has keys that are greater node value than root?

17
Q

Reverse a linked list using recursion and iteration

A
prev = None
        current = self.head 
        while(current is not None): 
            next = current.next
            current.next = prev 
            prev = current 
            current = next
        self.head = prev 
https://www.geeksforgeeks.org/reverse-a-linked-list/