← 返回博客列表
Goldman Sachs

Goldman Sachs 高盛 OA 真题分享

2025-09-28

高盛 OA 注重金融场景算法和数据结构。本文分享最OA 真题csvosupport* 助你拿到 Offer

📋 题目一:股票买卖最佳时

def maxProfit(prices):
    if not prices:
        return 0
    
    min_price = float('inf')
    max_profit = 0
    
    for price in prices:
        min_price = min(min_price, price)
        max_profit = max(max_profit, price - min_price)
    
    return max_profit

📋 题目二:合并区间

def merge(intervals):
    if not intervals:
        return []
    
    intervals.sort(key=lambda x: x[0])
    merged = [intervals[0]]
    
    for current in intervals[1:]:
        if current[0] <= merged[-1][1]:
            merged[-1][1] = max(merged[-1][1], current[1])
        else:
            merged.append(current)
    
    return merged

📋 题目三:LRU 缓存

from collections import OrderedDict

class LRUCache:
    def __init__(self, capacity):
        self.cache = OrderedDict()
        self.capacity = capacity
    
    def get(self, key):
        if key not in self.cache:
            return -1
        self.cache.move_to_end(key)
        return self.cache[key]
    
    def put(self, key, value):
        if key in self.cache:
            self.cache.move_to_end(key)
        self.cache[key] = value
        if len(self.cache) > self.capacity:
            self.cache.popitem(last=False)

💼 csvosupport 助力

金融场景 - 交易算法 数据结构 - 高级数据结构 代码质量 - 金融级代码标 时间管理 - 高效答题策略

联系 csvosupport,专业金OA 辅助


*标签 #GoldmanSachs #高盛 #OA #金融科技 #LRU #OA代做 #面试辅助 #一亩三分地


需要面试真题? 立刻联系微信 Coding0201,获得真题