Skip to content

siddharthrajaraja/Interview-Problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interview-Problems

Linus Torvals


Sorted and Rotated Array (Microsoft, https://codezen.codingninjas.in/practice/128432/3796/interview-shuriken-20:-sorted-and-rotated-array )


N-th Prefect Number (Microsoft, https://codezen.codingninjas.in/practice/130452/4641/interview-shuriken-21:-n-th-prefect-number)
Count distinct elements in every window of size k(Accolite, Amazon and Microsoft,https://codezen.codingninjas.in/practice/199644/5201/interview-shuriken-35:-count-distinct-elements-in-every-window-of-size-k)
Sort Binary Array (Amazon, Zoho, Paytm and MakeMyTrip , https://codezen.codingninjas.in/practice/236720/5537/interview-shuriken-40:-sort-binary-array)
First negative integer in every window of size k (Amazon,https://codezen.codingninjas.in/practice/194088/5171/interview-shuriken-34:-first-negative-integer-in-every-window-of-size-k)
Two Elements(Facebook, https://codezen.codingninjas.in/practice/177734/5008/interview-shuriken-30:-two-elements)
Move Zeroes to End(Amazon, Bloomberg, Paytm, LinkedIn, Samsung and SAP Labs, https://codezen.codingninjas.in/practice/240143/5577/interview-shuriken-41:-move-zeroes-to-end)
Delete Middle Node (Flipkart and Microsoft.,https://codezen.codingninjas.in/practice/253059/5741/interview-shuriken-43:-delete-middle-node)
Loop Detector (Amazon, Accolite, Samsung and MAQ Software ,https://codezen.codingninjas.in/practice/255594/5823/interview-shuriken-44:-loop-detector)
Pair Sum(initial rounds of Google interview, https://codezen.codingninjas.in/practice/100333/2674/interview-shuriken-1:-pair-sum)
Find the smallest window in a string containing all characters of another string( Amazon, Factset, MakeMyTrip, Codenation, Streamoid Technologies, Google, Visa, https://codezen.codingninjas.in/practice/209118/5331/interview-shuriken-37:-find-the-smallest-window-in-a-string-containing-all-characters-of-another-string)
Happy Number (https://codezen.codingninjas.in/practice/265704/5880/interview-shuriken-45:-happy-number)
Smallest window that contains all distinct characters(Microsoft, Amazon and DailyHunt,https://codezen.codingninjas.in/practice/188409/5167/interview-shuriken-33:-smallest-window-that-contains-all-distinct-characters)
Is Palindrome(Snapdeal, Microsoft and Amazon, https://codezen.codingninjas.in/practice/267994/5962/interview-shuriken-46:-is-palindrome)
Dynamic Programming --> Move_to_other_end ( Determine the minimum number of path taken by a pawn to travel from top-leftmost corner to bottom-right most corner in a n*n chessboard . Note : only Left and Bottom transitions allowed by the pawn. )
Amdocs Pattern : First line as n (number of lines)

4

1

3 * 2

4 * 5 * 6

10 * 9 * 8 * 7


328. Odd Even Linked List (https://leetcode.com/problems/odd-even-linked-list/), odd_even_link_list_o(n).c
21. Merge Two Sorted Lists (https://leetcode.com/problems/merge-two-sorted-lists/)
186. Reverse Words in String (Microsoft,Amazon,Uber, https://www.leetfree.com/problems/reverse-words-in-a-string-ii.html#)
54. SPIRAL MATRIX (Google, https://leetcode.com/problems/spiral-matrix/ ) -- > Given a matrix of R (Rows) and C(Columns) :

Print the elements of matrix in spiral order :

Example :

3 3

1 2 3

4 5 6

7 8 9

1 2 3 6 9 8 7 4 5


70. CLIMBING STAIRCASE (Amazon , https://leetcode.com/problems/climbing-stairs/)

Problem : CONTIGUOUS SUB-ARRAY SUM : (Google) : Given a contiguous array of size n of non-negative integers , find a contiguous sub-array which adds to give sum S. Time: O(n) Example : array : [1 2 3 7 5] S : 12 Output : [2, 4]


Problem : This problem was asked by Sumo Logic.

Given an unsorted array, in which all elements are distinct, find a "peak" element in O(log N) time.

An element is considered a peak if it is greater than both its left and right neighbors. It is guaranteed that the first and last elements are lower than all others.

Exmaple : INPUT :

15 20 14 16 48 19 50 60 10 20 30 45 60

OUTPUT :

YES

ALL PEAK ELEMENTS ARE : [20, 48, 60]


Problem : (Google interview) : Given two arrays A and B and a targetSum to be achieved , write a function that returns "True" or "False" such that : if a number choosen from A and a number choosen from B has a sum equal to targetSum.

Example:

Input : A=> [25 30 41 60 10 -5 60 -2] B=> [-1 0 20 60] tragetSum=> -3 Output : True


Problem: (Towers and Listeners) This problem was asked by Spotify.

You are the technical director of WSPT radio, serving listeners nationwide. For simplicity's sake we can consider each listener to live along a horizontal line stretching from 0 (west) to 1000 (east).

Given a list of N listeners, and a list of M radio towers, each placed at various locations along this line, determine what the minimum broadcast range would have to be in order for each listener's home to be covered.

For example, suppose listeners = [1, 5, 11, 20], and towers = [4, 8, 15]. In this case the minimum range would be 5, since that would be required for the tower at position 15 to reach the listener at position 20.


34. Find First and Last Position of Element in Sorted Array (Facebook ,https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/)
*PROBLEM:place_all_x_and_y_together* : This problem was asked by LinkedIn.

You are given a string consisting of the letters x and y, such as xyxxxyxyy. In addition, you have an operation called flip, which changes a single x to y or vice versa.

Determine how many times you would need to apply this operation to ensure that all x's come before all y's. In the preceding example, it suffices to flip the second and sixth characters, so you should return 2.


This problem was asked by Pinterest.

At a party, there is a single person who everyone knows, but who does not know anyone in return (the "celebrity"). To help figure out who this is, you have access to an O(1) method called knows(a, b), which returns True if person a knows person b, else False.

Given a list of N people and the above operation, find a way to identify the celebrity in O(N) time.

D:\C++ FILES>elexe
Enter number of relations : 6
sid aman
rohan aman
amulya aman
rohan amulya
ankita aman
vinay aman

Key Value
amulya aman
ankita aman
rohan aman amulya
sid aman
vinay aman

indegree map is : aman 5
amulya 1
ankita 0
rohan 0
sid 0
vinay 0
outdegree map is :
aman 0
amulya 1
ankita 1
rohan 2
sid 1
vinay 1
Celebrity is aman


List Shuffling

This problem was asked by Google.

link : https://leetcode.com/problems/range-sum-of-bst

Given a binary search tree and a range [a, b] (inclusive), return the sum of the elements of the binary search tree within the range.

For example, given the following tree:

5 

/ \

3 8

/ \ / \

2 4 6 10

and the range [4, 9], return 23 (5 + 4 + 6 + 8).


Interview Shuriken 54: Missing K Natural Numbers


Sentence Equality

This problem was asked by Google.

You are given a set of synonyms, such as (big, large) and (eat, consume). Using this set, determine if two sentences with the same number of words are equivalent.

For example, the following two sentences are equivalent:

"He wants to eat food." "He wants to consume food." Note that the synonyms (a, b) and (a, c) do not necessarily imply (b, c): consider the case of (coach, bus) and (coach, teacher).

Follow-up: what if we can assume that (a, b) and (a, c) do in fact imply (b, c)?


Interview Shuriken 55: Missing Numbers


This problem asked by : Amazon Interview Shuriken 26: Number of Islands


This problem asked by : Google Interview Shuriken 17: Sort RGB


This problem asked by : Amazon Interview Shuriken 15: Run Length Encoding


This problem asked by Google Unival Subtrees Leetcode


This problem was asked by Squarespace.

Write a function, add_subtract, which alternately adds and subtracts curried arguments. Here are some sample operations:

add_subtract(7) -> 7

add_subtract(1)(2)(3) -> 1 + 2 - 3 -> 0

add_subtract(-5)(10)(3)(9) -> -5 + 10 - 3 + 9 -> 11

Link to code curry.py


This problem was asked by Google Valid Parenthesis String


This Code is asked by Google Link to problem
Solution


This problem was asked by Amazon.

Write a function that takes a natural number as input and returns the number of digits the input has.

Constraint: don't use any loops.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published