⏱ 0:00est. 29 min
Salesforce
/*
Interviewer was friendly and polite. Ds algo, basics of js
Interview Questions
what is event loop ?
https://www.youtube.com/watch?v=8aGhZQkoFbQ
---
closure
"A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain.
The closure has three scope chains:
1. it has access to its own scope (variables defined between its curly brackets),
2. it has access to the outer function’s variables, and
3. it has access to the global variables
function greet(whattosay){
return function(name){
console.log(whattosay + ‘ ’ + name);
}
}
//We are invoking a function that returns a function so that we can invoke the returned function
greet(‘Hi’)(‘Tony’); // OUTPUT : Hi Tony
---
flat a nested array
I/P: [1,2,[3],[[4]],[[[5]]]]
O/P: [1,2,3,4,5]
etc
*/
let a = [1, 2, [3], [[4]], [[[5]]]];
console.log(a.flat(Infinity));
function flat(arr) {
return arr.reduce((acc, item, index, array) => {
return acc.concat(Array.isArray(item) ? flat(item) : item);
}, []);
}
console.log(flat(a));
// BFS
// LinkedList questions #TODO
// tree traversal
// lru cache #TODO
// overlapping rectangles problem #TODO
// https://leetcode.com/problems/rectangle-overlap/
/*
bool isRectangleOverlap(vector<int>& rec1, vector<int>& rec2) {
int x1 = rec1[0];
int y1 = rec1[1];
int x2 = rec1[2];
int y2 = rec1[3];
int p1 = rec2[0];
int q1 = rec2[1];
int p2 = rec2[2];
int q2 = rec2[3];
// first corrdinates of rec1 are less than ending coodinates of rec2
int bottom_left_of_rec1_is_less_than_top_right_of_rect2 = x1<p2 && y1<q2;
// begining coordinates of overlapping rec2 has to be less than ending coordinates rec1
int bottom_left_of_rect2_is_less_than_top_right_of_rect_1 = p1<x2 && q1<y2;
return bottom_left_of_rec1_is_less_than_top_right_of_rect2 && bottom_left_of_rect2_is_less_than_top_right_of_rect_1;
}
*/
// Implement reversing a linked list. #Done
/**
* Node * curr = head;
* Node * prev = NULL
* while(curr!=NULL) {
* Node *next = curr->next;
* curr->next = prev;
* prev = curr;
* curr = next;
* }
* return prev;
* /
// In a railway station, trains are arriving at every 10mins, another train arrives at once in every 15mins, how many platforms the station has
// Standard Array and sorting interview questions to evaluate your programming concepts
// I was asked to whiteboard FizBuzz.
for (var i = 1; i <= 100; i++) {
if (i % 15 == 0) console.log("FizzBuzz");
else if (i % 3 == 0) console.log("Fizz");
else if (i % 5 == 0) console.log("Buzz");
else console.log(i);
}
// Questions will be mostly on - Binary Trees, Topological Sorting, Stacks, Java/Javascript basics, OOP programming, System Design and its mostly open interview.
// Develop and run a program which has 2 arrays of any length with a set of negative,zero and positive numbers and a sum was provided. In the complexity o(n) identify the indexes of both the arrays whose sum of values form the given sum.
// Asked to code a tail recursion algorithm
// https://www.geeksforgeeks.org/tail-recursion/
// Explain binary search algorithm
// Design a dependency management system.
// Whiteboard how you design an online restaurant table reservation system.
// How to design and scale an e-mail gate service to validate spams
// Describe what happens from the moment you type a URL in your browser, until you see the page. Assume a Rails stack.
// topological sort
// Fibonacci sequence
int printKthFibonacci(int n)
{
if (n <= 1)
{
return n;
}
return printKthFibonacci(n - 1) + printKthFibonacci(n - 2);
}
int n = 9;
for (int i = 1; i < n; i++)
{
cout << printKthFibonacci(i) << "\n";
}
// palindrome checker
bool isPalindrome(string str, int start, int end)
{
if(start >= end)
return true;
return ((str[start]==str[end]) &&
isPalindrome(str, start + 1, end - 1));
}
// Do a producer consumer problem
// Reach 2D Pt x to Pt y in spiral form -> right -> down -> left -> up moving 1 point at a time.
/*
1) Describe Singleton in a Real Life Example , like if you want to explain concept of singleton pattern to your grandmother, who don't know the computer at all. what would be your approach.
2) How would you design a Chat Session (gtalk) ?
3) write program to calculate power(x,n) in log(n) time
// https://www.youtube.com/watch?v=l0YC3876qxg
4) Find intersection node of two linked lists.
6) Merge two sorted linked lists into one without extra space.
7) Given an array, which contains integers in the range of 1 to n. one number is missing from it and one number is repeated in array. for ex -- array is {1,2,3,4,4,6,7,8,9} , range given is 1- n(n=9).
// https://www.geeksforgeeks.org/find-a-repeating-and-a-missing-number/
8) given char array = {a,a,a,a,b,b,b,c,c,d,d,,e,,f,f}
output should be -- {a,4,b,3,c,2,d,2,e,f,2}, i.e. occurrences of every element followed by character, without using other array.
// https://www.geeksforgeeks.org/print-characters-frequencies-order-occurrence/
*/
/*
- Hiring manager stage: find all words which start from particular letter (case insensitive)
- Remote Coding Test stage: implements components installer (implement the following methods: MakeDependency(component1, component2) // makes component1 dependent on component2
Install(component1) // installs component1 and components it is dependent upon (if they're not installed already)
Remove(component2) // removes component1 and components it is dependent upon if they're not used by other installed components.
Note: component1 can be dependent on component2 and component3; and component4 can be dependent on component2
- On-site interview: lots of technical questions like implement itoa, find kth largest in array, how to implement unit-tests, lots of behavioral questions.
*/
/*
JS - what is eval()
// https://www.educative.io/edpresso/eval-vs-function-in-javascript
6. JS - what is the diffenrence between == and ===
7. Web - how do you keep information in a web application - cookie vs session
8. What is GET and POST - differences
9. How hashmaps work - hashCode and equals operators
10. Piriciples of OO - encapsulation, inheritance
11. What is synchronized?
12. Big O of data searching on different data structures - array , linked list, hashtable
13. Java difference of a hashtable and hashmap
14. Something that you are proud of - code and other - industry related
15. Describe a development process - engaging client - requirements - etc
16. Favorite java classes
17. What does AJAX stands for?
- Asynchronous JavaScript And XML
- it is the use of the XMLHttpRequest object to communicate with servers
- AJAX’s most appealing characteristic is its "asynchronous" nature, which means it can communicate with the server, exchange data, and update the page without having to refresh the page.
- Make requests to the server without reloading the page
- Receive and work with data from the server
// https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started
18. what type of response can you get from and AJAX call - string or XML
- it can send and receive information in various formats, including JSON, XML, HTML, and text files
*/
/*
- Given an ordered large array of integers, find all pairs of numbers that add up to a particular given sum.
- Given an NxN matrix, find out the number of ways to get to the NxNth cell from the 1x1 cell...
int recursive(int i, int j) {
if(i>N || J>N)
return 0;
if(i==N && j==N)
return 1;
return Recursive(i+1,j) + Recursive(i, j+1);
}
result = Recursive(0, 0);
*/
// maps, sets, trees, self-balancing trees, etc.
/*
Design on the whiteboard a data structure with the following requirements and explore various implementation's tradeoffs between space and speed.
1. Return true or false whether a given string exists in the dictionary.
2. Return the lexicographically first string within the dictionary of length N.
Explain how you would implement "Word Count".
Explain various concepts related to operating systems.
After conversing with my interviewer, since I knew what a Bloom filter was and other sketch data structures, I was asked to explain how a Bloom filter works.
*/
/*
//Identify the discrepancy between two mostly identical arrays.
//A = [3,1,4,5,2,6,6]
//B = [3,5,2,1,4,6]
Was also asked to create a more performant solution and analyze its complexity.
*/
/*
Designing minesweeper
Java Theoretical questions
*/
// Implement a Queue using a stack
// sort a list of numbers by the frequency of each number in the list, then optimize it.
// https://www.geeksforgeeks.org/queue-using-stacks/
// Design a card game for me.
// How would you implement a game like minesweeper
// finding middle of linked list, etc.), then asked to describe a file system layou
// Describe/code a Binary Tree implementation, code function to find a node in a binary tree, a binary search tree, code a function to add a node into a binary search tree, describe a technical project you've completed, there was a debugging question where they described a web application to me and asked me what I would do in certain scenarios where some sort of behavior was not working correctly. (3rd party APIs, callbacks, timeouts on requests, thread usage/exhaustion etc.)
// Perform a level-order traversal.
/*
1. Given a list of pin codes, print the frequency of all pin codes in sorted order. (Followed by questions on hashmap)
2. General OOPs questions - inheritance, polymorphism etc.
3. Design a game of tic-tac-toe.
4. Difference between SOAP/REST. Which one to prefer over the other and why?
5. Some CSS and JavaScript questions.
6. General resume walk-through and questions on my past internships/projects.
*/
// How would you implement a Stack if you're given access to a Queue API and only the Queue API?
/*
- Use two stacks to implement a queue.
- Find the median in an unsorted linked list.
- Datacenter/SQL question about joins and ordering
- Print out the boundary nodes of a binary tree
*/
/*
- Phone screen: fizz buzz
- Phone screen: "oh you know clojure? cool I don't know it; can you show me hello world?"
On site: second interview was all over the place. Asked me some statistics stuff, asked me some simple linked list things (finding middle of linked list, etc.), then asked to describe a file system layout (I was interviewing for an SRE/backend position)
*/
// Implement a queue, given 2 stacks.
/*
A couple simple questions about Binary Search Trees
- Creating a sorted list by extracting the min element n times
- two approaches to this: iterative approach and recursive approach
- Counting the frequency of words in a list
- hashtable with word keys and word count values
- Asked a bit about best coding practices (readability, safety from bugs etc..)
*/
// thread, garbage collection, encapsulation, plus one tree related algorithm question
// Explain / implement a hash table
// Lots of data structures questions. The one that I struggled the most with was: given an binary search tree (that is, an ordered tree), how would you find the element of the tree at a particular "index", where index is defined as the position in the tree's ordering.
/*
1. Xml format
2. Javascript basics
*/
/*
Increasing subsequence.
Given a post order traversal of a tree, find if it is a BST
*/
/*
Data modeling
Analytics
Web scrapping
System distribution
Optimisation
*/
/*
- Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.
Example 1:
Input: "abab"
Output: True
Explanation: It's the substring "ab" twice.
Example 2:
Input: "aba"
Output: False
Example 3:
Input: "abcabcabcabc"
Output: True
Explanation: It's the substring "abc" four times. (And the substring "abcabc" twice.)
- Given a list of non negative integers, arrange them such that they form the largest number.
Example 1:
Input: [10,2]
Output: "210"
Example 2:
Input: [3,30,34,5,9]
Output: "9534330"
Note: The result may be very large, so you need to return a string instead of an integer.
- Telephonic Interview:
- Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive 32-bit integer exists, you need to return -1.
Example 1:
Input: 12
Output: 21
Example 2:
Input: 21
Output: -1
- Telephonic Interview :
- Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.
If possible, output any possible result. If not possible, return the empty string.
Example 1:
Input: S = "aab"
Output: "aba"
Example 2:
Input: S = "aaab"
Output: ""
Note:
*/
/*
1. Design tiny URL
2. Design workflow management
3. written test - longest increasing subsequence, rest client to get some data over HTTP using pagination and deal the data conversions to get final result, One more
4. Friend function in C++
5. Few basic questions on Java
6. Few basic questions of Python - GIL, tuple as key in a dict, list as a key in dict e.t.c
7. GIT commands and usage - git fetch, pull, reset, stash e.t.c
*/
/*
As I have applied for UI position, most of the questions was regarding Accessibility
// https://a11ytips.dev/docs/interview-questions/
// ARIA stands for Accessible Rich Internet Application
// ARIA is useful for screenreader users
// In short, ARIA is the bridge between missing information in HTML and screenreaders.
- ES6 features
- Responsiveness
- Webpage Performance and Memory optimization related.
*/
/*
Questions were average, Like
- finding merge point in linked list
- design cache
- compare two binary trees etc
*/
/*
- Search in matrix
- rod cutting problem
- number up-side down etc..
*/
/*
1. REST API
2. SQL DML Queries.
3. Technical questions based on your resume.
4. What is SAAS ?
etc
*/
// Design some site like e-Seva for Electricity departments of different states.
/*
- Create a warehouse from an operational table so that only recent load dates sfdc ids will remain in the warehouse.
- Difference between relational & columnar data storage and how does it help.
*/
/*
Q: A row and column wise sorted matrix given. Print it in sorted order.
Q: Maximal Sum Path in a matrix (DP).
Q: Trapping Rain Water (O(n) solution).
Q: Some question on computing an expression. (Solved using stacks).
Q: Design questions.
*/
// BFS, String, Trees and OOPS.
// In the designing round I was asked to design object model for vehicle parking and in the technical round they concentrated on Apex coding skills.
/*
Write the function for level order traversal in a tree?
Write test cases.
Design and code a command line processor. the directory structure should be in cache and commands like mkdir, CD, ls, ls -R, touch, etc should work.
The program should exit when input is "quit".
Write test cases.
Design iPod shuffle, code the algorithm to shuffle songs in different albums, whereas the albums should always be in sorted order.
Design and code.
Every shuffle function call should generate a different sequence of songs than previous.
Write test cases.
Design book my show.
DB schema, class diagram.
How to manage concurrent requests.
What's encapsulation?
Write a function to sort an array in a way to create a zig zag graph if possible.
The array can have negative and duplicates but is of type integer.
Write test cases.
*/
/*
1. Arrange given numbers to form the biggest number.
2. Count smaller number on right side of array.
3. Tree related questions
*/
// Write code to list all such edges in a graph such that the removal of those edges would result in making the graph disjointed.
/*
1. Design a system for Point of Sale
2. Four different Coding exercises - Leetcode easy-medium
3. Another System Design question
4. Technical questions on Apex, LWC, Java, and JS
5. Questions on current work experience
6. knowledge test on their new systems
*/
/*
1. Variant of max sum in a binary tree (not a BST).
2. Some Network security and low level protocol questions.
3. Some behavioral questions.
*/
// Graph question
/*
A singly linked list with next and a random pointer is given. Min steps to reach end of linked list.
Given an undirected Garph and a source and destination . Find min distance.
Implement HashMap handling collision and all other feautres like put and get. Interviewer was looking to implment me in most efficient way.
An array is given with the value containing the index of the parent. Calculate height of tree in an eifficient way. WIthout using skeleton of tree(i.e without storing left and right child of a node)
Calculate max subarray XOR of an array. Expected complexity O(N)
Calculate all nodes at distance k from a given node. No parent pointer given.
Suppose i want to find all column whose name start with "Pas". How does database works in this case. I told about indexing. Then he asked me how does indexing works.
Detailed discussion on how we can make search efficient using trie.
*/
// Longest window of distinct letters in a string
// Given two sorted arrays of integers, A and B, find the set of n largest numbers where each number is the sum of an integer from A and an integer from B.
// Trees, List, Stack, Queues , Dynamic Programming
/*
Q:Find if the given binary tree is complete
Q:Swap the consequtive elements in a linked list
Q:Find the size of maximum square sub array with all ones in a binary 2D array.
*/
/*
In the first round i am asked three questions
1. Eliminate the duplicate elements from a given linked list.
2. One question on Permutations and Combinations
3. Union find algorithm.
*/
// Simple algorithms and finding diagnol elements in a binary tree
/*
Phone Interview :
1. Shallow copy deep copy
2. Serialization
3. Types of Thread synchronization
4. Hash Table n hash colision resolution techniques
5. Puzzle-join 4 dots using three lines
1:1 interview
1. Puzzle- Find minimum floor from which a tt ball will break, if there are 100 floor and 2 tt balls
2. In memory cache -design, problem an solutions
3. Find one/twomissing number in 1-n numbers
Online coding test -2 hours
1. Can browse net
2. Was given airlines portal sstem with api, write client code that uses api and write some code to add more exception scenarios, errors, scalable situations and race conditions
Hash Collision techniques
*/