JavaScript Coding Interview Questions PDF 1743762861
JavaScript Coding Interview Questions PDF 1743762861
Coding Interview
QuestioNS
@DimpleKumari
Forming a network of fantastic coders.
1. Arrays
Q1: Find the Maximum Subarray Sum (Kadane’s Algorithm)
Problem: Find the contiguous subarray with the largest sum.
Input: [-2,1,-3,4,-1,2,1,-5,4]
Output: 6 (subarray [4,-1,2,1])
Hint: Use a variable to track the maximum sum ending at the
current index and update a global maximum.
@DimpleKumari
Forming a network of fantastic coders.
1. Arrays
Q3: Find the First Missing Positive Integer
Problem: Find the smallest missing positive integer in an
unsorted array.
Input: [3, 4, -1, 1]
Output: 2
Hint: Use an in-place marking approach to track numbers.
@DimpleKumari
Forming a network of fantastic coders.
1. Arrays
Q5: Find the Kth Largest Element in an Array
Problem: Find the Kth largest element in an unsorted
array.
Input: nums = [3,2,1,5,6,4], k = 2
Output: 5
Hint: Use a min-heap or quickselect algorithm.
@DimpleKumari
Forming a network of fantastic coders.
2. Strings
Q1: Check If Two Strings Are Anagrams Without Sorting
Problem: Check if two strings are anagrams.
Input: "listen", "silent"
Output: true
Hint: Use a frequency count of characters.
@DimpleKumari
Forming a network of fantastic coders.
2. Strings
Q3: Convert a String to an Integer Without parseInt()
Problem: Implement a function to convert a string to an
integer.
Input: "-42"
Output: -42
Hint: Handle leading spaces, signs, and overflow cases
manually.
@DimpleKumari
Forming a network of fantastic coders.
2. Strings
Q5: Implement Run-Length Encoding
Problem: Compress a string using run-length encoding.
Input: "aaabbc"
Output: "a3b2c1"
Hint: Iterate through the string and keep track of
consecutive character counts.
@DimpleKumari
Forming a network of fantastic coders.
3. Numbers
Q1: Check If a Number is Power of Two
Input: 16
Output: true
Hint: A power of two has exactly one bit set in its binary
representation.
@DimpleKumari
Forming a network of fantastic coders.
3. Numbers
Q3: Find the Square Root Without Using Built-in Function
Problem: Implement a function to compute the integer part of the
square root of a number.
Input: 8
Output: 2
Hint: Use binary search between 1 and num/2 to find the largest
integer whose square is ≤ num.
@DimpleKumari
Forming a network of fantastic coders.
3. Numbers
Q5: Check If a Number is an Armstrong Number
Problem: Check if a number is an Armstrong number (sum of its
digits each raised to the power of the number of digits equals
the original number).
Input: 153
Output: true
Hint: Split the number into digits, raise each to the power of
the total number of digits, and sum them.
@DimpleKumari
Forming a network of fantastic coders.
FOLLOW
Dimple Kumari
Forming a network of fantastic coders.