Google Question - Paint Fence with circular fences

google logo
google
May 2, 2026 · 1 reads

Summary

I was asked a variation of the classic Paint Fence problem where the fences are arranged in a circular manner, making the first and last fence adjacent. I couldn't solve it during the interview.

Full Experience

Hi, yesterday I had interview with google, where I was asked question paint fence question (leetcode 276) but with a variation that fences are in circular order, that means first and last fence are adjacent. I was not able to solve it, later I asked claude, chatgpt, gemini, they were also not able to solve it. Do you guyz have any idea!

Interview Questions (1)

1.

Paint Fence with Circular Adjacency

Data Structures & Algorithms·Hard

Given n fences and k colors, paint all the fences such that no two adjacent fences (including the first and last fence which are considered adjacent due to circular arrangement) have the same color. Return the total number of ways to paint the fence.

📣 Found this helpful? Please share it with friends who are preparing for interviews!

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!