Google Question - Paint Fence with circular fences

Posted
2 May 2026
422 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.

How it went

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!

Questions asked (1)

  1. 01

    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.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Google recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

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