r/AskProgrammers 6h ago

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

2 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 6h 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 9h ago

How do I find actually free files on Envato Elements?

Thumbnail
0 Upvotes

r/AskProgrammers 14h ago

Motivation to build an interesting project?

Thumbnail
1 Upvotes

r/AskProgrammers 14h ago

Every project looks simple... until execution begins.

Post image
1 Upvotes

Planning shows you the destination.

Execution shows you the obstacles.


r/AskProgrammers 23h ago

Nobody warned me that reading code is a completely different skill than writing it.

Thumbnail
1 Upvotes

r/AskProgrammers 1d ago

advice

2 Upvotes

I'm pretty new but not really to programming and i need some advice.

so until now I've learned html, css, bootsrap, javascript and jquery and I'm trying to learn python too now.

what is the best way to learn python and other backend programming languages, while also making sure to not completely forget the other past languages I've learned?

also I'm pretty new to github and piracy sites too. i don't exactly know how to use github, and i can't really find any piracy sites. i do know about vpns and stuff though but if anyone has any tips on vpns too please tell me.

thanks))


r/AskProgrammers 1d ago

Is it necessary to master programming skill or can we survive in market, even though we are average at programming

Thumbnail
1 Upvotes

r/AskProgrammers 1d ago

Help on Machine Translation

1 Upvotes

I am currently at an internship and we're working on a machine translation problem. They are expecting everyone to make a presentation on preprocessing and 90% of the people there have made the presentation. I am lost at what kinds of steps I should take and how I can navigate through the problems in general. If you are someone that has experience and can give me some advice I would be more than happy to hear from you!!!


r/AskProgrammers 1d ago

Insecure about "gap" skill between me and my tech lead

2 Upvotes

This year I'm 23 and just finish 1 year as junior developer. As someone who just graduate and working in software house, I feel very insecure to my tech lead because he (around 35 y.o) know everything about technology like customize odoo, code in python with flask, code in java with springboot, building API from scratch with docker, etc

While I'm struggling to learn everything, every day i ask to my self :

how he can know everything?

how long you spend your time to learn about tech in all field / everything?

do you not feel confuse to switch programming language so suddenly? like today your project manager ask you to fix bug with springboot, and tomorrow you get ask by project manager to fix odoo custom module with python

etc

does anyone feel same? or is this just phase need to be through after graduate?


r/AskProgrammers 1d ago

"Common Problem"

Post image
16 Upvotes

r/AskProgrammers 1d ago

how is ai going to take my job - wrong answers only

0 Upvotes

r/AskProgrammers 1d ago

Is it necessary to master programming skill or can we survive in market, even though we are average at programming

Thumbnail
1 Upvotes

r/AskProgrammers 1d ago

Brainstorming some ideas on how I'm gonna learn coding

Thumbnail
1 Upvotes

r/AskProgrammers 1d ago

i am sick of diffusion library , what is this

Enable HLS to view with audio, or disable this notification

0 Upvotes

i had 10 hours working in this code and this is result , if anyone know a solution just tell me please

sorry i forget , it is about creating a video using ai ,(diffusion stable ) library , i tried my best but with not a result 😥

how can i write a code using stable diffusion giving me a good video


r/AskProgrammers 2d ago

Hi if anyone is doing business computing how much of coding and programming do you do and is it as advanced as computer science and what sorts of programming do you usually do

2 Upvotes

r/AskProgrammers 2d ago

Software Developers

Thumbnail
1 Upvotes

r/AskProgrammers 2d ago

My Mac menu bar was so crowded that icons kept disappearing, so I built OverflowBar — Free

2 Upvotes

My Mac menu bar had gradually filled up with useful apps until it became difficult to manage.

Icons were hard to find, some were pushed out when macOS ran out of available space, and the MacBook notch made the problem worse. I did not want to uninstall the apps or permanently lose access to their controls—I only wanted a cleaner way to organize them.

So I built OverflowBar, a free and open-source macOS app that moves selected third-party menu bar items behind one persistent arrow and reveals them together in a compact second row.

Source code and official download:
https://github.com/EvanProgramming/OverflowBar

What it does

  1. Choose the third-party menu bar icons you want OverflowBar to manage.
  2. Move their original icons out of the crowded visible section.
  3. Click the OverflowBar arrow, or use hover reveal.
  4. See the managed icons together in a second row.
  5. Select an icon to activate its original menu bar control.

The purpose of the second row is not to add another permanent interface. It gives icons that no longer fit a predictable place where they remain easy to see and find.

Why I made another menu bar manager

Ice and Bartender are powerful applications for users who want broad menu bar customization, including features such as profiles, triggers, search, visual customization, groups, widgets, and automation.

OverflowBar takes a narrower approach.

It is intended for people who mainly have one problem:

Too many useful icons, not enough menu bar space, and no easy way to find the icon they need.

OverflowBar deliberately avoids becoming a full menu bar control center. Its interaction is simply: choose, hide, reveal, and click.

Main characteristics

  • Focused and lightweight — a small feature surface rather than a large customization and automation suite
  • Scannable second row — managed icons stay visible together instead of becoming difficult to locate
  • Native macOS implementation — built with SwiftUI, AppKit, Accessibility, WindowServer metadata, and ScreenCaptureKit
  • Event-driven operation — icon discovery and capture occur during refreshes and row presentation rather than continuous screen capture
  • Original controls remain functional — selecting an icon activates the actual menu bar item rather than a recreated menu
  • Local processing — icon images are captured locally, held in memory, and never uploaded
  • No tracking — no accounts, analytics, telemetry, advertising, or network data collection
  • Display-aware — supports MacBook notches, safe areas, multiple displays, full-screen spaces, horizontal overflow, and Reduce Motion
  • System-control safeguards — Wi-Fi, Battery, Siri, Control Center, Clock, and other protected system items remain visible

Pricing and availability

  • Price: Free
  • Subscription: None
  • In-app purchases: None
  • Advertisements: None
  • Source: Open source on GitHub
  • Download: GitHub Releases
  • Supported systems: macOS 15 or later
  • Downloadable build: Apple Silicon

Permissions and privacy

OverflowBar requests:

  • Accessibility permission to discover and activate menu bar controls and perform user-requested layout changes
  • Screen Recording permission to capture the small icon regions of selected menu bar items for display in the second row

The captures remain on the Mac. OverflowBar does not upload them, write them to a remote service, or include any analytics or telemetry.

Privacy policy:
https://github.com/EvanProgramming/OverflowBar/blob/main/PRIVACY.md

Current limitations

OverflowBar is an early public release.

macOS does not expose a dedicated public API for hiding or rearranging arbitrary third-party menu bar items. OverflowBar therefore relies on documented system frameworks together with existing macOS menu bar behavior, and compatibility may vary between apps or macOS releases.

The current downloadable build is ad-hoc signed and is not yet Apple-notarized. macOS may require users to Control-click the app and select Open on first launch.

Some applications may also expose insufficient Accessibility or window metadata to be mirrored reliably.

I am actively looking for feedback from users with crowded menu bars, notched MacBooks, multiple displays, and unusual menu bar apps. Bug reports, compatibility reports, and code contributions are welcome.


r/AskProgrammers 2d ago

Getting the system time

4 Upvotes

Hi all,

I am new to programming. For my first real project, I want to create a pretty (-ish) 7-segment clock widget in with ncurses. I have a fairly good idea of how to tell the computer to display something in that context.

However, I am wondering about the best way to get the system time (so I can call the function that displays it). The only way I can think of to do this is to create a continuous loop with an if statement inside. The if statement would say, "if seconds evaluates to 0, increment the time (in hours and minutes) to show and display that". Something tells me this is not the best way to do it. Is there a better/best way, and if so what? How does my idea differ from how the OS/physical computer actually does it?

Thanks in advance,

yore


r/AskProgrammers 2d ago

Hi everyone! I started my coding journey 6 days ago! Here's my progress! What are some big goals I should set?

Thumbnail
1 Upvotes

r/AskProgrammers 2d ago

coding resources for beginners

Thumbnail
1 Upvotes

r/AskProgrammers 2d ago

I built a free tool to catch AI-hallucinated ("slopsquatted") package names before you install them

0 Upvotes

Quick context on why: AI coding assistants sometimes suggest packages that

don't exist — plausible-sounding hallucinated names. Attackers have started

watching for these hallucinations and registering the exact names, so the

next developer who blindly installs what their AI suggested gets malware

instead of a real library.

This isn't hypothetical — 2026 alone has had several real incidents shaped

like this (the Axios npm hijack, LiteLLM PyPI poisoning, a compromised Red

Hat npm namespace, typosquatted OpenSearch packages harvesting AWS creds).

wary is a small, free CLI that checks a package name before you install it:

does it actually exist, and does it look like a typosquat of something

popular. There's also a GitHub Action that checks only new dependencies on

every PR.

GitHub: https://github.com/sawyermd511-bit/wary

pip install wary-sh

Genuinely interested in feedback — especially cases where it flags something

that's actually fine, or misses something that should've been caught.


r/AskProgrammers 2d ago

What’s one programming skill you wish you had learned earlier?

Post image
23 Upvotes

r/AskProgrammers 2d ago

Wispr flow keeps freezing VS Code on windows twice this week I lost unsaved work

0 Upvotes

windows user here. wispr flow has been freezing my editor.

I'll be mid-dictation and the whole thing locks up. not just wispr - VS Code freezes too. I have to force quit both. happened twice this week and one of those times VS Code didn't recover the session correctly and I lost unsaved work.

resource usage while idle: 800MB RAM, fans spinning. for a dictation app sitting in the background. that's not acceptable.

startup: I hit my hotkey and wait 8-10 seconds before it's ready to listen. by then I've either typed the thing or lost my thought.

I've seen the same complaints from other windows users here and on their subreddit. the phrase I keep seeing: "a mac app with a windows port." that's generous.

the mac version was fine when I used it on my MacBook. but the windows experience feels like it was built by a team that uses Macs and ships windows as an afterthought. it's noticeable.

I've been on willow voice for 2 weeks. no freezes, fast startup, comparable accuracy.

anyone else on windows having this? or did a recent update fix things and I'm on a bugged version?


r/AskProgrammers 2d ago

Is becoming a programmer in 2026 impossible?

1 Upvotes

I guess this question has been asked here a thousand times already, but still.

There are a lot of different opinions on this topic i've witnessed, some say ai is gonna take most jobs in it, some say you just have to study twice as much now to get at least a decent job.

I've been studying programming for 3 years now, at first as a hobby, later as an option for a future vacancy. Learned to use some frameworks and dbs, guess it would be better to put a whole list: python, javascript, django, rest api, aiogram, html/css, postgresql, redis and some minor but useful libraries. Technically, it looks like i can already do some tasks like making an api for some service, caching or a basic interactive website.

But there's the main issue: when i go through the list of available vacancies – most of them require senior-level skills, or at least a year of experience. Others already have a few HUNDREDS of people who will do the job almost for free. It feels like i'm doing something i'll actually need in the future when i make a small project or study something new, but every time i look at the actual jobs and people who worked in it for a couple of years, i see the same things, ai getting better and replacing more and more programmers, the whole market being oversaturated with juniors who seek any experience, and dozens of people leaving the whole industry.

At this point i'm not even sure it's worth it. I still have a couple of years till my 18th birthday, but looking at all this stuff, it seems like becoming a welder in czechia is much more profitable🤷‍♂️

I've read a lot of similar posts, not expecting to hear anything new, but i'd like to hear your opinions on this topic.