<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KVGHS6G" height="0" width="0" style="display:none;visibility:hidden"></iframe>

Citadel计算机科学面试真题

职位分类
全部
数据相关
计算机科学
人工智能
产品经理
BQ
面试题
全部(97)
OOD(2)
Algorithm(76)
System Design(13)
高频题(0)
Math(2)
全部(97)
OOD(2)
Algorithm(76)
System Design(13)
高频题(0)
Math(2)
1.visiting cities
2.Count Subarrays with Sum Divisible by K
3.Lexicographical Numbers Ordering
4.Generating n-bit Gray Code Sequence
5.Shortest Subarray with Sum at Least K
6.Count Subarrays with Sum Divisible by K
7.Minimize Score After Adding or Subtracting K from Elements
8.Maximum Length of Turbulent Subarray
9.Count Subarrays with Sum Divisible by K
10.背包问题变种
11.Max num of chocolate
12.并查集问题
13.Even or odd
14.Longest subarray
15.Max Profit with At Most Two Stock Transactions
16.Valid Parentheses String Checker
17.Implement strStr() Function in String
18.Rearrange String to Avoid Adjacent Repeating Characters
19.Maximum Subarray
20.Shortest Path in a Traffic Network with Refueling Stations
21.Common Friends Problem
22.Palindromic Substrings
23.Expected number of keystrokes to type 'citadel'
24.Expected position of an accessed element in an LRU cache
25.Explain the geometric interpretation of Ax=b having zero, one, or infinitely many solutions
26.Optimization of a Brute Force Solution
27.Friend Recommendation System
28.Optimize Data Processing Pipeline Throughput
29.Optimizing Data Processing Pseudocode
30.Optimizing Pseudocode for Run-time
31.Improving Data Processing Pseudocode
32.Longest Sequence with Equal Endpoints Sum
33.ArrayList Manipulation Steps
34.Trie and Dynamic Programming Combination Problem
35.Friend Recommendation System
36.Count Stable Segments
37.Stable Segment
38.Distinct Goodness Values
39.Binary Search for Operations Optimization
40.Using HashMaps to Store Previous Occurrences of Numbers
41.Optimizing Data Retrieval with Prefix Sums
42.Optimal Job Execution Strategy
43.Sliding Window Minimum Frequency
44.Design a simple streaming system.
45.How do you review code and stay updated with state-of-the-art technology?
46.Optimal Scaling Configuration for Data Processing Pipeline
47.Maximum Length of Consistent Logs
48.Friend Recommendation System Prototype
49.Algorithm Correctness Verification
50.Implement Excel
51.Token Expiry System
52.Number of Distinct Palindromes in a Given String
53.Special Nodes in a Tree
54.Minimum Knight Moves on a Chess Board
55.Process Execution Optimization
56.Maximum Sum Path in a Tree
57.Strong Team Formation
58.Cache Definition and LFU Implementation
59.Building a Strong Hacker Team
60.Special Nodes in a Tree
61.Maximum Value Sum of Non-Empty Paths
62.First Lady of Software Algorithm
63.Tree Path Finding Problem
64.Dynamic Programming Problem
65.Integer Decomposition into Summands
66.Front-end Credit Card Form Component
67.Building a Strong Hacker Team
68.Find the Smallest Positive Integer Not in Array
69.Minimum Unreachable Vertices in a Directed Graph
70.Longest Common Substring with Character Operations
71.Optimized Fibonacci Sequence Calculation
72.Fibonacci Sequence with O(logN) Complexity
73.Implement Monte Carlo Method to Estimate Pi
74.Optimization Problem to Minimize Sum
75.Implement a Circular Queue using an Array
76.Hacker Team Problem using Dynamic Programming
77.Knight's Tour in Chess using BFS
78.Expected Steps to Exit a Grid
79.Variant of LeetCode Problem 23
80.Maximum of an Array with Minimum Comparisons
81.Numerical Analysis Challenge
82.Optimized Matrix Search
83.Median of a 2D Point Set
84.Sliding Windows Problem
85.Cache and CPU Related Concepts
86.Implementing a HashMap
87.Optimal Assignment Problem
88.Design a TinyURL System
89.Design a Message Queue
90.Code Review and Bug Identification
91.Analyze Code Output
92.Design a Key-Value Store
93.Implement str() Function
94.Optimal Road Transformation in Warehouse Network
95.Design a High Performance Logger
96.Special Nodes
97.Number of Moves
1. visiting cities

输入red,blue分别为长度为n的int arr,以及bluecost
red和blue为i-1城到城的距离,bluecost为红线转蓝线的距离,蓝转红无距离。
输出0号红站到1.2...n城的最短距离
例子:red=[5,5,5],blue=[3,3,3],bluecost=3,那么输出[0,5,9,12]
解释:0到0是0,0到1最近的是直接红线=5,0到2是转蓝(3+3)到1城,继续走蓝到2城(+3)
总共=9,0到3是3+3+3+3=12
2. Count Subarrays with Sum Divisible by K
Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k.

A subarray is a contiguous part of an array.

 

Example 1:

Input: nums = [4,5,0,-2,-3,1], k = 5
Output: 7
Explanation: There are 7 subarrays with a sum divisible by k = 5:
[4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3]

Example 2:

Input: nums = [5], k = 9
Output: 0

 

Constraints:

  • 1 <= nums.length <= 3 * 104
  • -104 <= nums[i] <= 104
  • 2 <= k <= 104
3. Lexicographical Numbers Ordering
Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order.

You must write an algorithm that runs in O(n) time and uses O(1) extra space. 

 

Example 1:

Input: n = 13
Output: [1,10,11,12,13,2,3,4,5,6,7,8,9]

Example 2:

Input: n = 2
Output: [1,2]

 

Constraints:

  • 1 <= n <= 5 * 104
4. Generating n-bit Gray Code Sequence
An n-bit gray code sequence is a sequence of 2n integers where:

  • Every integer is in the inclusive range [0, 2n - 1],
  • The first integer is 0,
  • An integer appears no more than once in the sequence,
  • The binary representation of every pair of adjacent integers differs by exactly one bit, and
  • The binary representation of the first and last integers differs by exactly one bit.
Given an integer n, return any valid n-bit gray code sequence.

 

Example 1:

Input: n = 2
Output: [0,1,3,2]
Explanation:
The binary representation of [0,1,3,2] is [00,01,11,10].
- 00 and 01 differ by one bit
- 01 and 11 differ by one bit
- 11 and 10 differ by one bit
- 10 and 00 differ by one bit
[0,2,3,1] is also a valid gray code sequence, whose binary representation is [00,10,11,01].
- 00 and 10 differ by one bit
- 10 and 11 differ by one bit
- 11 and 01 differ by one bit
- 01 and 00 differ by one bit

Example 2:

Input: n = 1
Output: [0,1]

 

Constraints:

  • 1 <= n <= 16
5. Shortest Subarray with Sum at Least K
Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1.

A subarray is a contiguous part of an array.

 

Example 1:

Input: nums = [1], k = 1
Output: 1

Example 2:

Input: nums = [1,2], k = 4
Output: -1

Example 3:

Input: nums = [2,-1,2], k = 3
Output: 3

 

Constraints:

  • 1 <= nums.length <= 105
  • -105 <= nums[i] <= 105
  • 1 <= k <= 109