Problem database last updated: June 20, 2025

SServiceNow logo

ServiceNow Coding Interview Questions

80 problems · 10 Easy, 59 Medium, 11 Hard · Ranked #30 of 458

Difficulty breakdown

10 Easy

13% · avg 23%

59 Medium

74% · avg 59%

11 Hard

14% · avg 18%

Top topics

array
60%
string
28.7%
dynamic-programming
23.8%
hash-table
20%
two-pointers
15%
stack
11.3%

Interview profile

Based on 80 reported problems, ServiceNow interviews are in line with industry averages - 14% Hard vs 18% overall. The majority (74%) of questions are Medium difficulty, which is typical for companies that want to see solid fundamentals without excessive trick questions.

Compared to the industry average, ServiceNow puts unusual emphasis on memoization (3.8% of problems, 2.3x the industry average), trie (5% of problems, 1.9x the industry average), queue (2.5% of problems, 1.7x the industry average). If you're short on time, these are the categories to double down on.

The most common topics are array (60%), string (28.7%), dynamic-programming (23.8%), hash-table (20%). Problems below are sorted by frequency, the ones at the top are asked most often.

All 80 problems

Subarray Product Less Than K

Solve

Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly le...

MediumVery Likely
arraybinary-searchsliding-window

Trapping Rain Water

Solve

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

HardVery Likely
arraytwo-pointersdynamic-programming

Group Anagrams

Solve

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

MediumVery Likely
arrayhash-tablestring

Valid Parentheses

Solve

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

EasyVery Likely
stringstack

LRU Cache

Solve

Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.

MediumVery Likely
hash-tablelinked-listdesign

Find Minimum Diameter After Merging Two Trees

Solve

There exist two undirected trees with n and m nodes, numbered from 0 to n - 1 and from 0 to m - 1, respectively. You are given two 2D integer arrays edges1 and...

HardVery Likely
treedepth-first-searchbreadth-first-search

Lexicographically Smallest String After Operations With Constraint

Solve

You are given a string s and an integer k.

MediumVery Likely
stringgreedy

Generate Parentheses

Solve

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

MediumVery Likely
stringdynamic-programmingbacktracking

Number of Distinct Roll Sequences

Solve

You are given an integer n. You roll a fair 6-sided dice n times. Determine the total number of distinct sequences of rolls possible such that the following con...

HardVery Likely
dynamic-programmingmemoization

Longest Substring Without Repeating Characters

Solve

Given a string s, find the length of the longest substring without duplicate characters.

MediumVery Likely
hash-tablestringsliding-window

Best Time to Buy and Sell Stock

Solve

You are given an array prices where prices[i] is the price of a given stock on the ith day.

EasyVery Likely
arraydynamic-programming

Design HashMap

Solve

Design a HashMap without using any built-in hash table libraries.

EasyVery Likely
arrayhash-tablelinked-list

Move Zeroes

Solve

Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.

EasyVery Likely
arraytwo-pointers

Zigzag Conversion

Solve

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better...

MediumVery Likely
string

Merge Intervals

Solve

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cove...

MediumVery Likely
arraysorting

Two Sum

Solve

Given an array of integers nums and an integer target, return the indices of the two numbers that add up to target.

EasyLikely
arrayhash-map

Daily Temperatures

Solve

Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait aft...

MediumLikely
arraystackmonotonic-stack

First Missing Positive

Solve

Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums.

HardLikely
arrayhash-table

Kth Largest Element in an Array

Solve

Given an integer array nums and an integer k, return the kth largest element in the array.

MediumLikely
arraydivide-and-conquersorting

Container With Most Water

Solve

You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).

MediumLikely
arraytwo-pointersgreedy

Maximal Square

Solve

Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.

MediumLikely
arraydynamic-programmingmatrix

String Compression

Solve

Given an array of characters chars, compress it using the following algorithm:

MediumLikely
two-pointersstring

Validate Binary Search Tree

Solve

Given the root of a binary tree, determine if it is a valid binary search tree (BST).

MediumLikely
treedepth-first-searchbinary-search-tree

Longest Palindromic Substring

Solve

Given a string s, return the longest palindromic substring in s.

MediumLikely
two-pointersstringdynamic-programming

Pacific Atlantic Water Flow

Solve

There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the...

MediumLikely
arraydepth-first-searchbreadth-first-search

LFU Cache

Solve

Design and implement a data structure for a Least Frequently Used (LFU) cache.

HardLikely
hash-tablelinked-listdesign

Top K Frequent Words

Solve

Given an array of strings words and an integer k, return the k most frequent strings.

MediumLikely
arrayhash-tablestring

Maximum Product Subarray

Solve

Given an integer array nums, find a subarray that has the largest product, and return the product.

MediumLikely
arraydynamic-programming

Number of Islands

Solve

Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.

MediumLikely
arraydepth-first-searchbreadth-first-search

Reverse Linked List

Solve

Given the head of a singly linked list, reverse the list, and return the reversed list.

EasyLikely
linked-listrecursion

Median of Two Sorted Arrays

Solve

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

HardLikely
arraybinary-searchdivide-and-conquer

Search in Rotated Sorted Array

Solve

There is an integer array nums sorted in ascending order (with distinct values).

MediumLikely
arraybinary-search

Set Matrix Zeroes

Solve

Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.

MediumLikely
arrayhash-tablematrix

Maximum Subarray

Solve

Given an integer array nums, find the subarray with the largest sum, and return its sum.

MediumLikely
arraydivide-and-conquerdynamic-programming

Largest Number

Solve

Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.

MediumLikely
arraystringgreedy

Binary Tree Right Side View

Solve

Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

MediumLikely
treedepth-first-searchbreadth-first-search

Asteroid Collision

Solve

We are given an array asteroids of integers representing asteroids in a row. The indices of the asteroid in the array represent their relative position in space...

MediumLikely
arraystacksimulation

Fraction to Recurring Decimal

Solve

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

MediumLikely
hash-tablemathstring

Valid Parenthesis String

Solve

Given a string s containing only three types of characters: '(', ')' and '', return true if s is valid.

MediumLikely
stringdynamic-programmingstack

Longest Consecutive Sequence

Solve

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

MediumLikely
arrayhash-tableunion-find

Validate IP Address

Solve

Given a string queryIP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type.

MediumLikely
string

Number of Visible People in a Queue

Solve

There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heig...

HardLikely
arraystackmonotonic-stack

First Unique Character in a String

Solve

Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.

EasyLikely
hash-tablestringqueue

Sum Root to Leaf Numbers

Solve

You are given the root of a binary tree containing digits from 0 to 9 only.

MediumLikely
treedepth-first-searchbinary-tree

Vowels of All Substrings

Solve

Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.

MediumLikely
mathstringdynamic-programming

Basic Calculator II

Solve

Given a string s which represents an expression, evaluate this expression and return its value.

MediumLikely
mathstringstack

Minimum Number of Taps to Open to Water a Garden

Solve

There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e., the length of the garden is n).

HardLikely
arraydynamic-programminggreedy

Rotting Oranges

Solve

You are given an m x n grid where each cell can have one of three values:

MediumLikely
arraybreadth-first-searchmatrix

Valid Palindrome

Solve

A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forwa...

EasyLikely
two-pointersstring

Target Sum

Solve

You are given an integer array nums and an integer target.

MediumLikely
arraydynamic-programmingbacktracking

Search Suggestions System

Solve

You are given an array of strings products and a string searchWord.

MediumLikely
arraystringbinary-search

Next Permutation

Solve

A permutation of an array of integers is an arrangement of its members into a sequence or linear order.

MediumLikely
arraytwo-pointers

Coin Change

Solve

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

MediumLikely
arraydynamic-programmingbreadth-first-search

Rotate Array

Solve

Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.

MediumLikely
arraymathtwo-pointers

Find First and Last Position of Element in Sorted Array

Solve

Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.

MediumLikely
arraybinary-search

Implement Trie (Prefix Tree)

Solve

A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various appl...

MediumLikely
hash-tablestringdesign

Single Element in a Sorted Array

Solve

You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.

MediumLikely
arraybinary-search

House Robber

Solve

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from rob...

MediumLikely
arraydynamic-programming

Sliding Window Maximum

Solve

You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see...

HardLikely
arrayqueuesliding-window

Gas Station

Solve

There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].

MediumLikely
arraygreedy

Palindrome Linked List

Solve

Given the head of a singly linked list, return true if it is a palindrome or false otherwise.

EasyLikely
linked-listtwo-pointersstack

3Sum

Solve

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

MediumLikely
arraytwo-pointerssorting

Find Minimum in Rotated Sorted Array

Solve

Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become:

MediumLikely
arraybinary-search

Find Peak Element

Solve

A peak element is an element that is strictly greater than its neighbors.

MediumLikely
arraybinary-search

Populating Next Right Pointers in Each Node

Solve

You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:

MediumLikely
linked-listtreedepth-first-search

Subarray Sum Equals K

Solve

Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.

MediumLikely
arrayhash-tableprefix-sum

Merge Sorted Array

Solve

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and num...

EasyLikely
arraytwo-pointerssorting

Word Break II

Solve

Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possi...

HardLikely
arrayhash-tablestring

Partition Equal Subset Sum

Solve

Given an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or false oth...

MediumLikely
arraydynamic-programming

Amount of Time for Binary Tree to Be Infected

Solve

You are given the root of a binary tree with unique values, and an integer start. At minute 0, an infection starts from the node with value start.

MediumLikely
hash-tabletreedepth-first-search

Check if a Parentheses String Can Be Valid

Solve

A parentheses string is a non-empty string consisting only of '(' and ')'. It is valid if any of the following conditions is true:

MediumLikely
stringstackgreedy

Minimum One Bit Operations to Make Integers Zero

Solve

Given an integer n, you must transform it into 0 using the following operations any number of times:

HardLikely
mathdynamic-programmingbit-manipulation

Binary Tree Zigzag Level Order Traversal

Solve

Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level...

MediumLikely
treebreadth-first-searchbinary-tree

4Sum

Solve

Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:

MediumLikely
arraytwo-pointerssorting

Permutations

Solve

Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.

MediumLikely
arraybacktracking

Letter Combinations of a Phone Number

Solve

Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.

MediumLikely
hash-tablestringbacktracking

Combination Sum

Solve

Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum...

MediumLikely
arraybacktracking

Jump Game

Solve

You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length...

MediumLikely
arraydynamic-programminggreedy

Pow(x, n)

Solve

Implement pow(x, n), which calculates x raised to the power n (i.e., xn).

MediumLikely
mathrecursion

Time Needed to Rearrange a Binary String

Solve

You are given a binary string s. In one second, all occurrences of "01" are simultaneously replaced with "10". This process repeats until no occurrences of "01"...

MediumLikely
stringdynamic-programmingsimulation

How often are these problems asked?

Frequency scores are based on crowdsourced interview reports. A higher score means the problem has been reported more often in recent ServiceNow interviews.

Very Likely

75-100%

Likely

50-74%

Sometimes

25-49%

Rare

0-24%

Preparing for your ServiceNow coding interview

ServiceNow interviews focus heavily on array, string, dynamic-programming problems. If you're short on time, these are the categories to prioritize. The problems on this page are sorted by frequency, so start from the top and work your way down.

Beyond solving problems, practice explaining your approach. ServiceNow interviewers care about your thought process - how you break down a problem, consider edge cases, and evaluate tradeoffs between solutions. A clean O(n) solution you can explain clearly beats an O(log n) solution you can't articulate.

Looking for more companies? Browse all 458 companies in our directory, or sharpen your fundamentals with our free data structure visualizers and AI-powered DSA tutor.

Frequently Asked Questions

What coding problems does ServiceNow ask in interviews?add

ServiceNow has been reported to ask 80 distinct coding problems. The most common topics are array, string, dynamic-programming. 10 are Easy difficulty, 59 are Medium, and 11 are Hard. Problems are sorted by frequency - the ones at the top are asked most often.

How hard are ServiceNow coding interviews?add

Based on 80 reported problems, ServiceNow interviews are in line with industry averages - 14% Hard vs 18% overall. 74% of questions are Medium difficulty. Focus on the high-frequency Medium problems first, then work through the Hard ones.

How should I prepare for a ServiceNow coding interview?add

Start with the highest-frequency problems listed on this page. Focus on the core topics: array, string, dynamic-programming. Practice solving them under time pressure and explaining your approach out loud. Mock interviews with AI can simulate the real experience.

Other companies to explore

Ready to ace your ServiceNow interview?

Simulate a real ServiceNow coding interview with an AI interviewer. Get a scorecard with specific feedback on your problem-solving, code quality, and communication.

Simulate a ServiceNow interview with AIarrow_forward