Skip to content

Instantly share code, notes, and snippets.

@qisantanu
Last active August 18, 2023 09:30
Show Gist options
  • Save qisantanu/b258db0667efa3ca22a50b9c93f032df to your computer and use it in GitHub Desktop.
Save qisantanu/b258db0667efa3ca22a50b9c93f032df to your computer and use it in GitHub Desktop.
Basic_interview

Basic Interview Questions

Can take help from https://github.com/DopplerHQ/awesome-interview-questions

C

  • What is data type in C?
  • What is sizeOf function in C?
  • What is syntax of ternary operator in C?
  • Difference between = and ==
  • What is pointer?
  • What is NULL pointer?
  • Swap two variables without using a third variable

Java

  • What is JVM and is it platform independent?
  • What is JDK/JVM/JRE?
  • What is OOPs cocnept? and describe the building blocks
  • What is inheritence? Describe through code
  • What is class in Java
  • Significance of Private/Public/Protected access specifiers
  • What is static and dynamic polymorphism (compile time and runtime polymorphism)
  • Abstract class and interface
  • Final variable/ Final method
  • Aggregation/Composition type associations - ?
  • Java Heap and Stack memory

Data Structure

  • What is data structure
  • What are the common operations you can perform on a data structures
  • How Array is different from LinkedList
  • Use case of Stack
  • Types of LinkedList
  • What is Binary Search
  • Can binary search be performed on a Linked List

DBMS

  • Advantages of Database over file system

  • What is primary/forign keys

  • What is DB Normalization

  • Write a SELECT statement

  • What is unique keya nd Fkey?

  • interview_tables

  • SQL query to fetch all the employees who are not working in any project

  • SQL query to fetch the employee name who has the lowest salary

  • SQL query to fetch the employee who is also manager

FE Concepts

  • What is Block and In line elements
  • What is <script> tag
  • How to define headings
  • What is Symantec HTML
  • Local Storage and Session Storage

Coding Challenges

  • Get sum and average of array
  • Sort an array of elements
  • Print 1-50 without using Loop
  • Palindrome
  • Reverse a string without using any library or inbuilt String methods
  • Armstrong number
  • Takes an input array and removes duplicate elements of it
  • Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Output: Because nums[0] + nums[1] == 9, we return [0, 1].
  • Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].
Input: nums = [1,2,3,4]
Output: [24,12,8,6]
  • Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6.
  • Given an array of integers, find the first repeating element in it. We need to find the element that occurs more than once and whose index of first occurrence is smallest.
Input:  arr[] = {10, 5, 3, 4, 3, 5, 6}
Output: 5 [5 is the first element that repeats]

Input:  arr[] = {6, 10, 5, 4, 9, 120, 4, 6, 10}
Output: 6 [6 is the first element that repeats]
  • Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
Input: s = "leetcode"
Output: 0
  • Write a program to print all 3 digit armstrong numbers

Javascript questions

  1. Is javascript a statically typed or a dynamically typed language? JavaScript is a dynamically typed language. In a dynamically typed language, the type of a variable is checked during run-time in contrast to a statically typed language, where the type of a variable is checked during compile-time.

https://d3n0h9tb65y8q.cloudfront.net/public_assets/assets/000/003/407/original/static_vs_dynamic.png?1654852333

What are callbacks?

A callback is a function that will be executed after another function gets executed. In javascript, functions are treated as first-class citizens, they can be used as an argument of another function, can be returned by another function, and can be used as a property of an object.

Functions that are used as an argument to another function are called callback functions. Example:

function divideByHalf(sum){ console.log(Math.floor(sum / 2)); }

function multiplyBy2(sum){ console.log(sum * 2); }

function operationOnSum(num1,num2,operation){ var sum = num1 + num2; operation(sum); }

operationOnSum(3, 3, divideByHalf); // Outputs 3

operationOnSum(5, 5, multiplyBy2); // Outputs 20 In the code above, we are performing mathematical operations on the sum of two numbers. The operationOnSum function takes 3 arguments, the first number, the second number, and the operation that is to be performed on their sum (callback). Both divideByHalf and multiplyBy2 functions are used as callback functions in the code above. These callback functions will be executed only after the function operationOnSum is executed. Therefore, a callback is a function that will be executed after another function gets executed.

Assignment 1:

getCompany()
console.log(x)
console.log(getCompany)
console.log(getCompany2)
getCompany2()

var x = 10;

function getCompany() {
  console.log("QI")
}

var getCompany2 = () => {
  console.log("Continental")
}

Assignment 2

What is closure? A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function's scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.

Advantages of Closure

  • JS did not have the native way to do the private methods, Using closure we can achive that. Private method helps to restric the access to the code. Disadvantages of Closures?
  • The variables declared inside a closure are not garbage collected.
  • Too many closures can slow down your application. This is actually caused by duplication of code in the memory.
function xtimeout() {
  for(var i = 1; i<6; i ++) {
    setTimeout(function() {
      console.log(i)
    }, i*1000)
  }
  console.log("QI")
}

xtimeout()
console.log("Continental")

 Assignment 2.1

function xtimeoutProper() {
  for(var i = 1; i<6; i ++) {
    function close(x) {
      setTimeout(function() {
      console.log(x)
      console.log(Date())
    }, x*1000)
    }
    

    close(i)
  }
  console.log("QI")
}

xtimeoutProper()

More: https://github.com/ignacio-chiazzo/Algorithms-Leetcode-Javascript/blob/master/LeetcodeProblems/Algorithms/3SumClosest.js

Problem:

Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.

A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment