Add office photos
Facebook logo
Employer?
Claim Account for FREE

Facebook

4.3
based on 161 Reviews
Video summary
Filter interviews by
Software Developer Intern
Fresher
Clear (1)

Facebook Software Developer Intern Interview Questions and Answers

Updated 5 Feb 2024

Q1. Base 58 Conversion Problem Statement

You are given a decimal number 'N'. Your task is to convert this number into a base 58 representation.

The Base58 alphabet is defined by the following characters: “123456789...read more

Ans.

Convert a decimal number to base 58 using a specific alphabet.

  • Iterate through each test case and convert the decimal number to base 58 using the given alphabet.

  • Handle the conversion by dividing the number by 58 and taking the remainder to find the corresponding base 58 character.

  • Build the base 58 representation by appending the characters in reverse order.

  • Output the final base 58 representation for each test case.

Add your answer
right arrow

Q2. Bird and Maximum Fruit-Gathering Problem Statement

A ninja bird can gather fruits from trees arranged in a circle. Each tree has an associated fruit value. The bird can gather all the fruits from a tree in 0.5 ...read more

Ans.

The task is to find the maximum number of fruits a bird can gather within a given time frame, moving between adjacent trees.

  • Start from each tree and calculate the maximum fruits that can be gathered within the time frame.

  • Use a sliding window approach to keep track of the fruits collected while moving between trees.

  • Choose the starting tree that gives the maximum total fruits collected.

  • Example: For input N=7, M=3, ARR={2, 1, 3, 5, 0, 1, 4}, the output is 9 by starting from tree...read more

Add your answer
right arrow
Facebook Software Developer Intern Interview Questions and Answers for Freshers
illustration image

Q3. Triplets with Given Sum Problem

Given an array or list ARR consisting of N integers, your task is to identify all distinct triplets within the array that sum up to a specified number K.

Explanation:

A triplet i...read more

Ans.

The task is to find all distinct triplets in an array that sum up to a specified number.

  • Iterate through the array and use nested loops to find all possible triplets.

  • Use a set to store unique triplets and check if the sum equals the target sum.

  • Handle edge cases like duplicate elements and no valid triplets.

  • Return the triplets or -1 if no valid triplet exists.

Add your answer
right arrow

Q4. Pair Sum Problem Statement

You are provided with an array ARR consisting of N distinct integers in ascending order and an integer TARGET. Your objective is to count all the distinct pairs in ARR whose sum equal...read more

Ans.

Count distinct pairs in an array whose sum equals a given target.

  • Use two pointers approach to iterate through the array and find pairs with sum equal to target.

  • Keep track of visited pairs to avoid counting duplicates.

  • Return -1 if no such pair exists with the given target.

Add your answer
right arrow
Discover Facebook interview dos and don'ts from real experiences

Q5. All Prime Numbers Less Than or Equal to N

Given a positive integer N, your task is to return all the prime numbers less than or equal to N.

Note:

1) A prime number is a number that has only two factors: 1 and t...read more
Ans.

Return all prime numbers less than or equal to a given positive integer N.

  • Iterate from 2 to N and check if each number is prime using a helper function.

  • A number is prime if it has only 2 factors: 1 and itself.

  • Optimize by checking divisibility only up to square root of the number.

Add your answer
right arrow

Q6. Running Absolute Difference in Arrays

Given an array ARR consisting of 'N' non-negative integers, compute the running absolute difference of elements at even and odd index positions, respectively.

Input:

An int...read more
Ans.

Compute running absolute difference of elements at even and odd index positions in an array.

  • Iterate through the array and calculate absolute difference between elements at even and odd indices.

  • Keep track of running absolute differences for even and odd indices separately.

  • Output the final running absolute differences for even and odd indices.

Add your answer
right arrow
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Developer Intern Interview Questions from Similar Companies

View all
Recently Viewed
INTERVIEWS
HCLTech
5.6k top interview questions
SALARIES
Gayatri Projects
SALARIES
METRO Global Solutions Center
INTERVIEWS
Facebook
No Interviews
SALARIES
Par Pharmaceutical Companies
INTERVIEWS
Facebook
Fresher
20 top interview questions
INTERVIEWS
Tech Mahindra
5.6k top interview questions
SALARIES
Impetus Technologies
SALARIES
Microsoft Corporation
SALARIES
Hexaware Technologies
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter