JP Morgan计算机科学面试真题

职位分类
全部
数据相关
计算机科学
人工智能
产品经理
BQ
面试题
全部(23)
OOD(3)
Algorithm(15)
System Design(4)
高频题(0)
Math(0)
全部(23)
OOD(3)
Algorithm(15)
System Design(4)
高频题(0)
Math(0)
1.Factors of 3 and 5
2.Longest Even Length Word
3.Design an Instagram-like Photo Sharing Service
4.Rearranging a Word to the Next Alphabetically Greater String
5.Is It Possible to Convert a Pair of Integers
6.Longest Even Length Word
7.Minimum Number of Flips to Achieve Target Binary String
8.Is Possible
9.Minimum Number of Flips to Convert Binary String to Target
10.Experience with Generics in Java
11.Experience with Threads in Java
12.Sorting a List of Users by Default
13.LLM Chatbot System Design
14.Balanced Or Not?
15.Is Possible
16.Maximum Sum with Fixed Jump Interval
17.Largest Number by Swapping Digits
18.Array Reduction Algorithm
19.Maximum Number of Pairs Selection
20.Handling Distributed System Issues
21.Distributed Lock Implementation
22.Discuss the complexity of operations in a linked list, including variants like cycles and arbitrary loops, and methods to detect them.
23.Identify three major differences between C++ and Python.
1. Factors of 3 and 5
An ideal number is a positive integer with only 3 and 5 as prime divisors. It can be expressed in the form of 3^x * 5^y, where x and y are non-negative integers. For example, 15, 45, and 75 are ideal numbers but 6, 70, and 27 are not. Find the number of ideal integers within the given segment [low, high] inclusive. For instance, in the range [200, 405], there are 4 ideal integers: 225 (3^2 * 5^2), 243 (3^5), 375 (3^1 * 5^3), and 405 (3^4 * 5^1). Write a function 'getIdealNums' that returns the number of ideal integers in the inclusive range specified by 'low' and 'high'.
2. Longest Even Length Word
Consider a string, sentence, of words separated by spaces where each word is a substring consisting of English alphabetic letters only. Find the first word in the sentence that has a length which is both an even number and greater than or equal to the length of any other word of even length in the sentence. If there are multiple words meeting the criteria, return the one which occurs first in the sentence. For example, given the sentence 'Time to write great code', the longest even length words are 'Time' and 'code'. The one that occurs first is 'Time', which is the answer to return. Write a function 'longestEvenWord' that returns the first occurrence of a word with maximal even number length, or the string '00' if there are no even length words.
3. Design an Instagram-like Photo Sharing Service
Design a system for uploading and sharing photos similar to Instagram. Discuss the expected number of users, frequency of use, storage space estimations, and the database requirements. Consider using Amazon S3 for photo storage, SQL database for photo metadata, a load balancer in front of the backend, and multiple read-only databases. Discuss how to handle high-profile users' photos, propose adding an image cache, and suggest storing metadata in memory and pre-storing thumbnail images in the cache for faster user load times without accessing S3 or the database. Additionally, discuss system crash scenarios, such as automatic server failover in Amazon Cloud and global data center distribution to handle regional outages. Finally, consider the need for a feed subsystem that pre-prepares and pushes data to each client periodically.
4. Rearranging a Word to the Next Alphabetically Greater String
Given a word, return the next alphabetically greater string that can be formed by rearranging its letters. If no such rearrangement is possible, return 'no answer'.
5. Is It Possible to Convert a Pair of Integers
Given a pair of integers (a, b), you can perform any of the following operations zero or more times: (a, b) -> (a + b, b) or (a, b) -> (a, a + b). Determine if it is possible to convert the pair (a, b) into another pair (c, d) by performing these operations. If it is possible, return 'Yes'; otherwise, return 'No'.