0% found this document useful (0 votes)
6 views

JavaScript Coding Interview Questions PDF 1743762861

The document contains a series of coding interview questions categorized into three sections: Arrays, Strings, and Numbers. Each question includes a problem statement, input examples, expected output, and hints for solving the problem. The questions cover various algorithms and data structures, providing a comprehensive resource for coding interview preparation.

Uploaded by

swatirout1022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

JavaScript Coding Interview Questions PDF 1743762861

The document contains a series of coding interview questions categorized into three sections: Arrays, Strings, and Numbers. Each question includes a problem statement, input examples, expected output, and hints for solving the problem. The questions cover various algorithms and data structures, providing a comprehensive resource for coding interview preparation.

Uploaded by

swatirout1022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

JavaScript

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.

Q2: Find the Longest Consecutive Sequence


Problem: Given an unsorted array, find the longest consecutive
sequence.
Input: [100, 4, 200, 1, 3, 2]
Output: 4 (sequence: [1,2,3,4])
Hint: Store numbers in a Set and check for the start of a sequence.

@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.

Q4: Sort an Array of 0s, 1s, and 2s Without Sorting


Problem: Sort an array containing only 0s, 1s, and 2s.
Input: [2,0,2,1,1,0]
Output: [0,0,1,1,2,2]
Hint: Use three pointers to rearrange numbers in a single pass

@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.

Q2: Find the Longest Palindromic Substring


Problem: Find the longest palindromic substring in a given
string.
Input: "babad"
Output: "bab" or "aba"
Hint: Expand around centers or use dynamic programming.

@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.

Q4: Find the First Non-Repeating Character in a String


Problem: Return the index of the first unique character.
Input: "leetcode"
Output: 0 (character: 'l')
Hint: Use a hash map to count character occurrences.

@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.

Q2: Check If a Number is Prime


Problem: Implement a function to check if a number is
prime.
Input: 7
Output: true
Hint: A prime number is only divisible by 1 and itself. Check
divisibility up to sqrt(n).

@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.

Q4: Convert a Number to Roman Numerals


Problem: Convert an integer to a Roman numeral representation.
Input: 58
Output: "LVIII"
Hint: Use a mapping of values {1000: 'M', 900: 'CM', 500: 'D', 400:
'CD', ...} and greedily subtract the largest possible value.

@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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy