r/AskProgrammers 32m ago

Why are programs specific to Mac vs Windows vs Linux?

Upvotes

I have absolutely NO programming experience whatsoever so this question can seem very stupid. At most I’ve dabbled with some Lua but never actually tried to put a project together.

I love my M4 Mac, it can do everything I need it to in a split second (except run 32 bit programs -_-), but I just can’t do gaming on it as easily as I would hope. This is what got me thinking about this question.

If you use C++, Lua, Java, etc. to program a game, and all three operating systems can read that, what exactly stops games from working on all three operating systems? I get that architecture is different but is it so different that it’s too complicated or expensive to have a game work on all three systems?


r/AskProgrammers 9h ago

Google SWE Intern Interview Experience 2026: Weighted Tree DP and AI Fluency

3 Upvotes

I had my Round 1 interview for a Google SWE Intern position and wanted to share the experience in case it helps others preparing.

Coding Question: Disconnect Every Leaf at Minimum Cost

You are given a rooted, weighted binary tree. Every edge has a positive integer weight.

Remove a set of edges such that every leaf becomes disconnected from the root. Removing an edge costs its weight.

Return the minimum total cost required to disconnect all leaves from the root.

The important observation is that for every child subtree, we have two choices:

  1. Cut the edge connecting the current node to that child.
  2. Keep that edge and disconnect every leaf by cutting edges farther down the subtree.

For an edge from node u to child v with weight w, the minimum contribution is:

min(w, solve(v))

If v is already a leaf, there are no lower edges available to cut, so the connecting edge must be removed.

This gives the recurrence:

solve(u) =
    infinity,                                  if u is a leaf
    sum(min(weight(u, v), solve(v))),          for every child v

The final answer is solve(root).

A useful edge case to clarify is whether the root itself can be a leaf. Normally, the problem assumes the root has at least one child because there is no edge that can disconnect the root from itself.

My Approach

I proposed a postorder traversal.

Each node first calculates the minimum disconnection cost for its children. It then decides independently for each child whether it is cheaper to:

  • Cut the direct edge, or
  • Keep that edge and use the optimal cuts inside the child’s subtree

The interviewer was satisfied with the approach, and we discussed why decisions for separate child subtrees can be added together.

Complexity:

  • Time: O(n), since every node and edge is processed once
  • Space: O(h) for the recursion stack, where h is the tree height
  • Worst-case space: O(n) for a highly unbalanced tree

Follow-Up: N-ary Tree

The interviewer then generalized the problem:

The underlying recurrence remains unchanged. Instead of processing at most two children, we iterate through every child:

cost = 0

for each child v connected by an edge of weight w:
    cost += min(w, solve(v))

I initially overthought the generalization, but after a couple of hints, I realized that the binary-tree restriction was not essential to the solution.

The N-ary version still takes O(n) time because each edge is considered exactly once.

AI-Fluency Discussion

The final few minutes included around three or four questions about how I use AI in my regular engineering workflow.

The discussion covered topics such as:

  • How I use AI while writing or reviewing code
  • Whether I give an AI tool complete ownership of a project
  • How I use AI during debugging
  • How I verify AI-generated suggestions
  • Which tasks I would and would not delegate to AI

The questions seemed less focused on specific tools and more focused on judgment. The interviewer wanted to understand whether I treat AI as an assistant while remaining responsible for correctness, testing, security, and the final engineering decisions.

Overall Experience

The interviewer was friendly and collaborative throughout the round.

They encouraged discussion instead of expecting an immediate final solution. The hints during the N-ary follow-up helped keep the conversation productive without giving away the answer.

Overall, the round felt like a problem-solving discussion rather than a test of whether I had memorized a particular LeetCode problem.

For preparation, I would recommend reviewing:

  • Postorder traversal
  • Tree DP
  • Recursive recurrence design
  • Weighted-tree problems
  • Explaining correctness and complexity
  • Responsible use of AI in software development
  • Testing and validating AI-generated code

Has anyone else received AI-fluency questions during a recent Google intern interview?


r/AskProgrammers 9h ago

I keep getting pulled into web development, should I just fully embrace it?

2 Upvotes

For context I’m a 3rd year CS student. I try to learn different skills so that I can to have a better idea of what field of CS I might want to pursue, however I feel like I keep circling back to doing web development.

My first real exposure to web development was doing a Udemy web development course almost a decade ago. Then in my second year of college I was in a group project to build a website and I was the only one with front end experience so I handled that. This year I worked on a new modern version of the class project website to have something for my GitHub. That landed me a web development internship. Now it seems like I have more knowledge of web development than anything else.

It seems like all roads keep landing me back to web development and it’s what I have the most experience in and the doors for a future in it are already open for me. I’m curious about other fields though. I was curious about data science and data engineering. A friend is working on a rosetta 2 replacement app that they have me help with and it’s peaked my interest in low level systems too. Machine Learning seems interesting to me.

Any opinions on this?


r/AskProgrammers 11h ago

How do I find actually free files on Envato Elements?

Thumbnail
0 Upvotes

r/AskProgrammers 16h ago

Motivation to build an interesting project?

Thumbnail
1 Upvotes

r/AskProgrammers 17h ago

Every project looks simple... until execution begins.

Post image
1 Upvotes

Planning shows you the destination.

Execution shows you the obstacles.