23. Edit distance on two large files
You compare two 100,000-line files using the full O(m × n) edit distance table on lines. Why do tools like git diff not do this?
- A.It needs about 10^10 cells; diff tools use Myers’ O(N × D) method
- B.Edit distance cannot compare lines, only characters
- C.The result would always be zero for text files
- D.Git stores files as trees, so no diff is needed
Show answer
Answer: A. It needs about 10^10 cells; diff tools use Myers’ O(N × D) method
100,000 × 100,000 is 10^10 cells, too much time and memory. Myers’ algorithm costs O(N × D), where D is the number of differences, so it is fast when files are similar, which is the usual case. Git also offers patience and histogram diff for more readable results.
24. Holding a rebasing token in a pool
A vault records each user's deposit of a rebasing token as a fixed number. The token's supply later rebases down 10%. What happens?
- A.The vault's records adjust automatically
- B.The rebase skips any balances held by contracts
- C.The vault holds less than it records; late users lose
- D.Users each get 10% more than they deposited
Show answer
Answer: C. The vault holds less than it records; late users lose
Rebasing tokens change balances in every wallet, including contract balances, without transfers. Fixed per-user records drift from reality. Tracking shares of the vault's actual balance, or using a non-rebasing wrapper, keeps accounting correct.
25. Secrets in a GitOps repo
Your team uses Argo CD and wants everything in Git, including database credentials. Which approach keeps GitOps without storing plaintext secrets in Git?
- A.Commit ExternalSecret references synced from a secret manager, or encrypted values with Sealed Secrets or SOPS.
- B.Commit plain Kubernetes Secret YAML to a private repo, since only the team can read a private repo.
- C.Base64 encode every value twice before committing, so nobody browsing the repo can read them.
- D.Keep secrets only as Argo CD UI parameter overrides, which are never saved anywhere outside the UI.
Show answer
Answer: A. Commit ExternalSecret references synced from a secret manager, or encrypted values with Sealed Secrets or SOPS.
GitOps wants the desired state in Git, but secret values do not need to be there in plaintext. ExternalSecret manifests describe where to fetch a secret, and the operator creates the Kubernetes Secret in-cluster, which also eases rotation. Sealed Secrets and SOPS store encrypted data that only the cluster or holders of the key can decrypt. Private repos still leak via clones, forks and CI logs.
26. Main breaks with two green PRs
PR A renames a function and PR B adds a new call to the old name. Each passes CI on its own branch, both are merged, and main fails to build. What prevents this?
- A.Requiring two reviewers on every pull request
- B.Running the full test suite nightly on main
- C.A merge queue that tests each PR on top of the latest main
- D.Squash merging every PR into one commit
Show answer
Answer: C. A merge queue that tests each PR on top of the latest main
Each PR was tested against an older main, so their combination was never built. A merge queue (GitHub merge queue, GitLab merge trains) builds each PR together with the PRs ahead of it and merges only if that combined result passes. Nightly runs find the break hours later.
27. Recovering after a bad force push
You ran `git reset --hard HEAD~3` on your feature branch by mistake and then force-pushed. The 3 commits are gone from the remote branch. How can you get them back from your own machine?
- A.Run git revert HEAD~3 to restore the deleted commits
- B.Find the old commit in git reflog, reset to it, and push again
- C.Run git fetch, as the remote keeps every forced commit
- D.They are lost; Git deletes them at the force push
Show answer
Answer: B. Find the old commit in git reflog, reset to it, and push again
The reflog records where HEAD and branches pointed, so the old tip is still listed, for example as HEAD@{1}. git reset --hard to that commit, then force-push again (prefer --force-with-lease). Unreachable commits stay until garbage collection, usually weeks later.
28. Self-hosted runners on a public repo
An open-source project uses a self-hosted runner inside the company network for faster builds, and runs CI on pull requests from forks. What is the risk?
- A.Anyone can open a PR that runs code inside your network
- B.Forks cannot trigger workflows on self-hosted runners
- C.The runner leaks its CPU model in the logs
- D.Public repos cannot use self-hosted runners at all
Show answer
Answer: A. Anyone can open a PR that runs code inside your network
A pull request can change the workflow or test code, so an outsider gets to run anything on that machine, reach internal systems and leave malware behind for later jobs. GitHub advises against self-hosted runners for public repos. Use hosted or isolated ephemeral runners, and require approval for outside contributors.
29. Workflows approving pull requests
A repo requires one approval to merge to main. A workflow using GITHUB_TOKEN can create a PR with changes and then approve it. What setting stops automation from satisfying the review rule?
- A.Give GITHUB_TOKEN write-all permissions in the repo
- B.Require every PR title to start with the word "fix:"
- C.Run the workflow only on weekends when few people work
- D.Stop GitHub Actions from creating and approving PRs
Show answer
Answer: D. Stop GitHub Actions from creating and approving PRs
If a workflow can approve PRs, anyone who can change or trigger that workflow can get code onto main without a human review. GitHub has an org and repo setting to stop Actions from creating or approving PRs. Also limit token permissions and require review from code owners.
30. Releasing a shared internal module
Twenty stacks use your internal network module from a Git repo. You need to make a breaking change. What is the safest release practice?
- A.Copy the module into each of the twenty repos
- B.Push to main so every stack gets the change on its next plan
- C.Change the module and run apply on all twenty stacks at once
- D.Tag a new major version; stacks move via ?ref= when ready
Show answer
Answer: D. Tag a new major version; stacks move via ?ref= when ready
Pinning module sources to tags, such as git::https://...?ref=v3.0.0, lets consumers upgrade one at a time and read the plan for each. Semantic versions tell them when a change is breaking. Tracking main means one merge can change twenty plans at once.
31. Test environments nobody deletes
Engineers spin up test stacks for pull requests, and many are never removed. What is the most robust way to control this cost?
- A.Send every engineer a monthly reminder email
- B.Allow only one engineer to create test stacks
- C.Give test stacks the largest instances available
- D.Auto-delete stacks via expiry tags or pipeline teardown
Show answer
Answer: D. Auto-delete stacks via expiry tags or pipeline teardown
Automation beats reminders: create ephemeral environments from the pipeline, destroy them when the pull request closes, and run a scheduled cleaner that deletes anything past an expiry tag. Use budgets on sandbox accounts as a backstop.
32. Running only affected tests
To speed up pull requests, you run only tests mapped to changed files (test impact analysis). What safeguard is most important?
- A.None; the mapping is always correct
- B.Run impacted tests only on Fridays
- C.Delete tests that are rarely selected
- D.Still run the full suite on main or on a schedule, and always run everything when shared code, config or dependencies change
Show answer
Answer: D. Still run the full suite on main or on a schedule, and always run everything when shared code, config or dependencies change
Dependency maps miss indirect effects such as configuration, data and runtime behaviour. A full run as a safety net catches what selection missed, while pull requests still get fast feedback.
33. Running only the affected tests
A monorepo's full suite takes 90 minutes. The team wants pull requests to run only tests affected by the change. What is the main risk to manage?
- A.Running fewer tests always lowers code coverage numbers in reports
- B.Affected-test selection works only for UI tests, never for unit tests
- C.Developers will write fewer tests once the whole suite runs faster
- D.Missed links, such as config or data files, so full runs are still needed
Show answer
Answer: D. Missed links, such as config or data files, so full runs are still needed
Test impact analysis maps code to tests using dependency graphs or coverage data, but changes to config, data files, environment or dynamic code paths can be missed. Teams pair it with full runs on merge or nightly as a safety net.