<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Chatmagic blog]]></title><description><![CDATA[Chatmagic blog]]></description><link>https://blog.chatmagic.app</link><generator>RSS for Node</generator><lastBuildDate>Sun, 03 May 2026 12:21:37 GMT</lastBuildDate><atom:link href="https://blog.chatmagic.app/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Top  VMware Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at VMware.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - help...]]></description><link>https://blog.chatmagic.app/top-vmware-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-vmware-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:59 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at VMware.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-koko-eating-bananashttpsleetcodecomproblemskoko-eating-bananas">Problem #1: <a target="_blank" href="https://leetcode.com/problems/koko-eating-bananas">Koko Eating Bananas</a></h1>
<blockquote>
<p>Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours. Koko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of bananas and eats k bananas from that pile. If the pile has less than k bananas, she eats all of them instead and will not eat any more bananas during this hour. Koko likes to eat slowly but still wants to finish eating all the bananas before the guards return. Return the minimum integer k such that she can eat all the bananas within h hours.   Example 1:  Input: piles = [3,6,7,11], h = 8 Output: 4  Example 2:  Input: piles = [30,11,23,4,20], h = 5 Output: 30  Example 3:  Input: piles = [30,11,23,4,20], h = 6 Output: 23    Constraints:  1 &lt;= piles.length &lt;= 104 piles.length &lt;= h &lt;= 109 1 &lt;= piles[i] &lt;= 109  </p>
</blockquote>
<p>Topics: Array, Binary Search</p>
]]></content:encoded></item><item><title><![CDATA[Top 2 Stripe Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Stripe.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - help...]]></description><link>https://blog.chatmagic.app/top-2-stripe-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-2-stripe-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:59 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Stripe.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-cheapest-flights-within-k-stopshttpsleetcodecomproblemscheapest-flights-within-k-stops">Problem #1: <a target="_blank" href="https://leetcode.com/problems/cheapest-flights-within-k-stops">Cheapest Flights Within K Stops</a></h1>
<blockquote>
<p>There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi to city toi with cost pricei. You are also given three integers src, dst, and k, return the cheapest price from src to dst with at most k stops. If there is no such route, return -1.   Example 1:   Input: n = 4, flights = [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]], src = 0, dst = 3, k = 1 Output: 700 Explanation: The graph is shown above. The optimal path with at most 1 stop from city 0 to 3 is marked in red and has cost 100 + 600 = 700. Note that the path through cities [0,1,2,3] is cheaper but is invalid because it uses 2 stops.  Example 2:   Input: n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 1 Output: 200 Explanation: The graph is shown above. The optimal path with at most 1 stop from city 0 to 2 is marked in red and has cost 100 + 100 = 200.  Example 3:   Input: n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 0 Output: 500 Explanation: The graph is shown above. The optimal path with no stops from city 0 to 2 is marked in red and has cost 500.    Constraints:  1 &lt;= n &lt;= 100 0 &lt;= flights.length &lt;= (n * (n - 1) / 2) flights[i].length == 3 0 &lt;= fromi, toi &lt; n fromi != toi 1 &lt;= pricei &lt;= 104 There will not be any multiple flights between two cities. 0 &lt;= src, dst, k &lt; n src != dst  </p>
</blockquote>
<p>Topics: Dynamic Programming, Depth-First Search, Breadth-First Search, Graph, Heap (Priority Queue), Shortest Path</p>
<h1 id="heading-problem-2-parallel-courses-iiihttpsleetcodecomproblemsparallel-courses-iii">Problem #2: <a target="_blank" href="https://leetcode.com/problems/parallel-courses-iii">Parallel Courses III</a></h1>
<blockquote>
<p>You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [prevCoursej, nextCoursej] denotes that course prevCoursej has to be completed before course nextCoursej (prerequisite relationship). Furthermore, you are given a 0-indexed integer array time where time[i] denotes how many months it takes to complete the (i+1)th course. You must find the minimum number of months needed to complete all the courses following these rules:  You may start taking a course at any time if the prerequisites are met. Any number of courses can be taken at the same time.  Return the minimum number of months needed to complete all the courses. Note: The test cases are generated such that it is possible to complete every course (i.e., the graph is a directed acyclic graph).   Example 1:   Input: n = 3, relations = [[1,3],[2,3]], time = [3,2,5] Output: 8 Explanation: The figure above represents the given graph and the time required to complete each course.  We start course 1 and course 2 simultaneously at month 0. Course 1 takes 3 months and course 2 takes 2 months to complete respectively. Thus, the earliest time we can start course 3 is at month 3, and the total time required is 3 + 5 = 8 months.  Example 2:   Input: n = 5, relations = [[1,5],[2,5],[3,5],[3,4],[4,5]], time = [1,2,3,4,5] Output: 12 Explanation: The figure above represents the given graph and the time required to complete each course. You can start courses 1, 2, and 3 at month 0. You can complete them after 1, 2, and 3 months respectively. Course 4 can be taken only after course 3 is completed, i.e., after 3 months. It is completed after 3 + 4 = 7 months. Course 5 can be taken only after courses 1, 2, 3, and 4 have been completed, i.e., after max(1,2,3,7) = 7 months. Thus, the minimum time needed to complete all the courses is 7 + 5 = 12 months.    Constraints:  1 &lt;= n &lt;= 5 <em> 104 0 &lt;= relations.length &lt;= min(n </em> (n - 1) / 2, 5 * 104) relations[j].length == 2 1 &lt;= prevCoursej, nextCoursej &lt;= n prevCoursej != nextCoursej All the pairs [prevCoursej, nextCoursej] are unique. time.length == n 1 &lt;= time[i] &lt;= 104 The given graph is a directed acyclic graph.  </p>
</blockquote>
<p>Topics: Array, Dynamic Programming, Graph, Topological Sort</p>
]]></content:encoded></item><item><title><![CDATA[Top 2 Twilio Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Twilio.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - help...]]></description><link>https://blog.chatmagic.app/top-2-twilio-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-2-twilio-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:59 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Twilio.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-maximize-greatness-of-an-arrayhttpsleetcodecomproblemsmaximize-greatness-of-an-array">Problem #1: <a target="_blank" href="https://leetcode.com/problems/maximize-greatness-of-an-array">Maximize Greatness of an Array</a></h1>
<blockquote>
<p>You are given a 0-indexed integer array nums. You are allowed to permute nums into a new array perm of your choosing. We define the greatness of nums be the number of indices 0 &lt;= i &lt; nums.length for which perm[i] &gt; nums[i]. Return the maximum possible greatness you can achieve after permuting nums.   Example 1:  Input: nums = [1,3,5,2,1,3,1] Output: 4 Explanation: One of the optimal rearrangements is perm = [2,5,1,3,3,1,1]. At indices = 0, 1, 3, and 4, perm[i] &gt; nums[i]. Hence, we return 4. Example 2:  Input: nums = [1,2,3,4] Output: 3 Explanation: We can prove the optimal perm is [2,3,4,1]. At indices = 0, 1, and 2, perm[i] &gt; nums[i]. Hence, we return 3.    Constraints:  1 &lt;= nums.length &lt;= 105 0 &lt;= nums[i] &lt;= 109  </p>
</blockquote>
<p>Topics: Array, Two Pointers, Greedy, Sorting</p>
<h1 id="heading-problem-2-ways-to-make-a-fair-arrayhttpsleetcodecomproblemsways-to-make-a-fair-array">Problem #2: <a target="_blank" href="https://leetcode.com/problems/ways-to-make-a-fair-array">Ways to Make a Fair Array</a></h1>
<blockquote>
<p>You are given an integer array nums. You can choose exactly one index (0-indexed) and remove the element. Notice that the index of the elements may change after the removal. For example, if nums = [6,1,7,4,1]:  Choosing to remove index 1 results in nums = [6,7,4,1]. Choosing to remove index 2 results in nums = [6,1,4,1]. Choosing to remove index 4 results in nums = [6,1,7,4].  An array is fair if the sum of the odd-indexed values equals the sum of the even-indexed values. Return the number of indices that you could choose such that after the removal, nums is fair.    Example 1:  Input: nums = [2,1,6,4] Output: 1 Explanation: Remove index 0: [1,6,4] -&gt; Even sum: 1 + 4 = 5. Odd sum: 6. Not fair. Remove index 1: [2,6,4] -&gt; Even sum: 2 + 4 = 6. Odd sum: 6. Fair. Remove index 2: [2,1,4] -&gt; Even sum: 2 + 4 = 6. Odd sum: 1. Not fair. Remove index 3: [2,1,6] -&gt; Even sum: 2 + 6 = 8. Odd sum: 1. Not fair. There is 1 index that you can remove to make nums fair.  Example 2:  Input: nums = [1,1,1] Output: 3 Explanation: You can remove any index and the remaining array is fair.  Example 3:  Input: nums = [1,2,3] Output: 0 Explanation: You cannot make a fair array after removing any index.    Constraints:  1 &lt;= nums.length &lt;= 105 1 &lt;= nums[i] &lt;= 104  </p>
</blockquote>
<p>Topics: Array, Prefix Sum</p>
]]></content:encoded></item><item><title><![CDATA[Top 2 Ozon Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Ozon.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - helpin...]]></description><link>https://blog.chatmagic.app/top-2-ozon-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-2-ozon-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:59 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Ozon.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-department-top-three-salarieshttpsleetcodecomproblemsdepartment-top-three-salaries">Problem #1: <a target="_blank" href="https://leetcode.com/problems/department-top-three-salaries">Department Top Three Salaries</a></h1>
<blockquote>
<p>Table: Employee  +--------------+---------+ | Column Name  | Type    | +--------------+---------+ | id           | int     | | name         | varchar | | salary       | int     | | departmentId | int     | +--------------+---------+ id is the primary key (column with unique values) for this table. departmentId is a foreign key (reference column) of the ID from the Department table. Each row of this table indicates the ID, name, and salary of an employee. It also contains the ID of their department.    Table: Department  +-------------+---------+ | Column Name | Type    | +-------------+---------+ | id          | int     | | name        | varchar | +-------------+---------+ id is the primary key (column with unique values) for this table. Each row of this table indicates the ID of a department and its name.    A company's executives are interested in seeing who earns the most money in each of the company's departments. A high earner in a department is an employee who has a salary in the top three unique salaries for that department. Write a solution to find the employees who are high earners in each of the departments. Return the result table in any order. The result format is in the following example.   Example 1:  Input:  Employee table: +----+-------+--------+--------------+ | id | name  | salary | departmentId | +----+-------+--------+--------------+ | 1  | Joe   | 85000  | 1            | | 2  | Henry | 80000  | 2            | | 3  | Sam   | 60000  | 2            | | 4  | Max   | 90000  | 1            | | 5  | Janet | 69000  | 1            | | 6  | Randy | 85000  | 1            | | 7  | Will  | 70000  | 1            | +----+-------+--------+--------------+ Department table: +----+-------+ | id | name  | +----+-------+ | 1  | IT    | | 2  | Sales | +----+-------+ Output:  +------------+----------+--------+ | Department | Employee | Salary | +------------+----------+--------+ | IT         | Max      | 90000  | | IT         | Joe      | 85000  | | IT         | Randy    | 85000  | | IT         | Will     | 70000  | | Sales      | Henry    | 80000  | | Sales      | Sam      | 60000  | +------------+----------+--------+ Explanation:  In the IT department: - Max earns the highest unique salary - Both Randy and Joe earn the second-highest unique salary - Will earns the third-highest unique salary  In the Sales department: - Henry earns the highest salary - Sam earns the second-highest salary - There is no third-highest salary as there are only two employees    Constraints:  There are no employees with the exact same name, salary and department.  </p>
</blockquote>
<p>Topics: Database</p>
<h1 id="heading-problem-2-monotonic-arrayhttpsleetcodecomproblemsmonotonic-array">Problem #2: <a target="_blank" href="https://leetcode.com/problems/monotonic-array">Monotonic Array</a></h1>
<blockquote>
<p>An array is monotonic if it is either monotone increasing or monotone decreasing. An array nums is monotone increasing if for all i &lt;= j, nums[i] &lt;= nums[j]. An array nums is monotone decreasing if for all i &lt;= j, nums[i] &gt;= nums[j]. Given an integer array nums, return true if the given array is monotonic, or false otherwise.   Example 1:  Input: nums = [1,2,2,3] Output: true  Example 2:  Input: nums = [6,5,4,4] Output: true  Example 3:  Input: nums = [1,3,2] Output: false    Constraints:  1 &lt;= nums.length &lt;= 105 -105 &lt;= nums[i] &lt;= 105  </p>
</blockquote>
<p>Topics: Array</p>
]]></content:encoded></item><item><title><![CDATA[Top 2 Yahoo Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Yahoo.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - helpi...]]></description><link>https://blog.chatmagic.app/top-2-yahoo-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-2-yahoo-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:58 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Yahoo.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-combination-sumhttpsleetcodecomproblemscombination-sum">Problem #1: <a target="_blank" href="https://leetcode.com/problems/combination-sum">Combination Sum</a></h1>
<blockquote>
<p>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 to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of times. Two combinations are unique if the frequency of at least one of the chosen numbers is different. The test cases are generated such that the number of unique combinations that sum up to target is less than 150 combinations for the given input.   Example 1:  Input: candidates = [2,3,6,7], target = 7 Output: [[2,2,3],[7]] Explanation: 2 and 3 are candidates, and 2 + 2 + 3 = 7. Note that 2 can be used multiple times. 7 is a candidate, and 7 = 7. These are the only two combinations.  Example 2:  Input: candidates = [2,3,5], target = 8 Output: [[2,2,2,2],[2,3,3],[3,5]]  Example 3:  Input: candidates = [2], target = 1 Output: []    Constraints:  1 &lt;= candidates.length &lt;= 30 2 &lt;= candidates[i] &lt;= 40 All elements of candidates are distinct. 1 &lt;= target &lt;= 40  </p>
</blockquote>
<p>Topics: Array, Backtracking</p>
<h1 id="heading-problem-2-subarray-sum-equals-khttpsleetcodecomproblemssubarray-sum-equals-k">Problem #2: <a target="_blank" href="https://leetcode.com/problems/subarray-sum-equals-k">Subarray Sum Equals K</a></h1>
<blockquote>
<p>Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. A subarray is a contiguous non-empty sequence of elements within an array.   Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Input: nums = [1,2,3], k = 3 Output: 2    Constraints:  1 &lt;= nums.length &lt;= 2 * 104 -1000 &lt;= nums[i] &lt;= 1000 -107 &lt;= k &lt;= 107  </p>
</blockquote>
<p>Topics: Array, Hash Table, Prefix Sum</p>
]]></content:encoded></item><item><title><![CDATA[Top 10 LinkedIn Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at LinkedIn.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - he...]]></description><link>https://blog.chatmagic.app/top-10-linkedin-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-10-linkedin-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:58 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at LinkedIn.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-3-all-oone-data-structurehttpsleetcodecomproblemsall-oone-data-structure">Problem #3: <a target="_blank" href="https://leetcode.com/problems/all-oone-data-structure">All O`one Data Structure</a></h1>
<blockquote>
<p>Design a data structure to store the strings' count with the ability to return the strings with minimum and maximum counts. Implement the AllOne class:  AllOne() Initializes the object of the data structure. inc(String key) Increments the count of the string key by 1. If key does not exist in the data structure, insert it with count 1. dec(String key) Decrements the count of the string key by 1. If the count of key is 0 after the decrement, remove it from the data structure. It is guaranteed that key exists in the data structure before the decrement. getMaxKey() Returns one of the keys with the maximal count. If no element exists, return an empty string "". getMinKey() Returns one of the keys with the minimum count. If no element exists, return an empty string "".  Note that each function must run in O(1) average time complexity.   Example 1:  Input ["AllOne", "inc", "inc", "getMaxKey", "getMinKey", "inc", "getMaxKey", "getMinKey"] [[], ["hello"], ["hello"], [], [], ["leet"], [], []] Output [null, null, null, "hello", "hello", null, "hello", "leet"]  Explanation AllOne allOne = new AllOne(); allOne.inc("hello"); allOne.inc("hello"); allOne.getMaxKey(); // return "hello" allOne.getMinKey(); // return "hello" allOne.inc("leet"); allOne.getMaxKey(); // return "hello" allOne.getMinKey(); // return "leet"    Constraints:  1 &lt;= key.length &lt;= 10 key consists of lowercase English letters. It is guaranteed that for each call to dec, key is existing in the data structure. At most 5 * 104 calls will be made to inc, dec, getMaxKey, and getMinKey.  </p>
</blockquote>
<p>Topics: Hash Table, Linked List, Design, Doubly-Linked List</p>
<h1 id="heading-problem-4-valid-parentheseshttpsleetcodecomproblemsvalid-parentheses">Problem #4: <a target="_blank" href="https://leetcode.com/problems/valid-parentheses">Valid Parentheses</a></h1>
<blockquote>
<p>Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if:  Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type.    Example 1:  Input: s = "()" Output: true  Example 2:  Input: s = "()[]{}" Output: true  Example 3:  Input: s = "(]" Output: false  Example 4:  Input: s = "([])" Output: true    Constraints:  1 &lt;= s.length &lt;= 104 s consists of parentheses only '()[]{}'.  </p>
</blockquote>
<p>Topics: String, Stack</p>
<h1 id="heading-problem-5-max-consecutive-ones-iiihttpsleetcodecomproblemsmax-consecutive-ones-iii">Problem #5: <a target="_blank" href="https://leetcode.com/problems/max-consecutive-ones-iii">Max Consecutive Ones III</a></h1>
<blockquote>
<p>Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.   Example 1:  Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2 Output: 6 Explanation: [1,1,1,0,0,1,1,1,1,1,1] Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. Example 2:  Input: nums = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], k = 3 Output: 10 Explanation: [0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1] Bolded numbers were flipped from 0 to 1. The longest subarray is underlined.    Constraints:  1 &lt;= nums.length &lt;= 105 nums[i] is either 0 or 1. 0 &lt;= k &lt;= nums.length  </p>
</blockquote>
<p>Topics: Array, Binary Search, Sliding Window, Prefix Sum</p>
<h1 id="heading-problem-6-maximum-subarrayhttpsleetcodecomproblemsmaximum-subarray">Problem #6: <a target="_blank" href="https://leetcode.com/problems/maximum-subarray">Maximum Subarray</a></h1>
<blockquote>
<p>Given an integer array nums, find the subarray with the largest sum, and return its sum.   Example 1:  Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: The subarray [4,-1,2,1] has the largest sum 6.  Example 2:  Input: nums = [1] Output: 1 Explanation: The subarray [1] has the largest sum 1.  Example 3:  Input: nums = [5,4,-1,7,8] Output: 23 Explanation: The subarray [5,4,-1,7,8] has the largest sum 23.    Constraints:  1 &lt;= nums.length &lt;= 105 -104 &lt;= nums[i] &lt;= 104    Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. </p>
</blockquote>
<p>Topics: Array, Divide and Conquer, Dynamic Programming</p>
<h1 id="heading-problem-10-number-of-islandshttpsleetcodecomproblemsnumber-of-islands">Problem #10: <a target="_blank" href="https://leetcode.com/problems/number-of-islands">Number of Islands</a></h1>
<blockquote>
<p>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. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.   Example 1:  Input: grid = [   ["1","1","1","1","0"],   ["1","1","0","1","0"],   ["1","1","0","0","0"],   ["0","0","0","0","0"] ] Output: 1  Example 2:  Input: grid = [   ["1","1","0","0","0"],   ["1","1","0","0","0"],   ["0","0","1","0","0"],   ["0","0","0","1","1"] ] Output: 3    Constraints:  m == grid.length n == grid[i].length 1 &lt;= m, n &lt;= 300 grid[i][j] is '0' or '1'.  </p>
</blockquote>
<p>Topics: Array, Depth-First Search, Breadth-First Search, Union Find, Matrix</p>
]]></content:encoded></item><item><title><![CDATA[Top 5 Palantir Technologies Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Palantir Technologies.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and eff...]]></description><link>https://blog.chatmagic.app/top-5-palantir-technologies-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-5-palantir-technologies-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:58 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Palantir Technologies.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-find-beautiful-indices-in-the-given-array-ihttpsleetcodecomproblemsfind-beautiful-indices-in-the-given-array-i">Problem #1: <a target="_blank" href="https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i">Find Beautiful Indices in the Given Array I</a></h1>
<blockquote>
<p>You are given a 0-indexed string s, a string a, a string b, and an integer k. An index i is beautiful if:  0 &lt;= i &lt;= s.length - a.length s[i..(i + a.length - 1)] == a There exists an index j such that:      0 &lt;= j &lt;= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| &lt;= k    Return the array that contains beautiful indices in sorted order from smallest to largest.   Example 1:  Input: s = "isawsquirrelnearmysquirrelhouseohmy", a = "my", b = "squirrel", k = 15 Output: [16,33] Explanation: There are 2 beautiful indices: [16,33]. - The index 16 is beautiful as s[16..17] == "my" and there exists an index 4 with s[4..11] == "squirrel" and |16 - 4| &lt;= 15. - The index 33 is beautiful as s[33..34] == "my" and there exists an index 18 with s[18..25] == "squirrel" and |33 - 18| &lt;= 15. Thus we return [16,33] as the result.  Example 2:  Input: s = "abcd", a = "a", b = "a", k = 4 Output: [0] Explanation: There is 1 beautiful index: [0]. - The index 0 is beautiful as s[0..0] == "a" and there exists an index 0 with s[0..0] == "a" and |0 - 0| &lt;= 4. Thus we return [0] as the result.    Constraints:  1 &lt;= k &lt;= s.length &lt;= 105 1 &lt;= a.length, b.length &lt;= 10 s, a, and b contain only lowercase English letters.  </p>
</blockquote>
<p>Topics: Two Pointers, String, Binary Search, Rolling Hash, String Matching, Hash Function</p>
<h1 id="heading-problem-2-find-beautiful-indices-in-the-given-array-iihttpsleetcodecomproblemsfind-beautiful-indices-in-the-given-array-ii">Problem #2: <a target="_blank" href="https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-ii">Find Beautiful Indices in the Given Array II</a></h1>
<blockquote>
<p>You are given a 0-indexed string s, a string a, a string b, and an integer k. An index i is beautiful if:  0 &lt;= i &lt;= s.length - a.length s[i..(i + a.length - 1)] == a There exists an index j such that:      0 &lt;= j &lt;= s.length - b.length s[j..(j + b.length - 1)] == b |j - i| &lt;= k    Return the array that contains beautiful indices in sorted order from smallest to largest.   Example 1:  Input: s = "isawsquirrelnearmysquirrelhouseohmy", a = "my", b = "squirrel", k = 15 Output: [16,33] Explanation: There are 2 beautiful indices: [16,33]. - The index 16 is beautiful as s[16..17] == "my" and there exists an index 4 with s[4..11] == "squirrel" and |16 - 4| &lt;= 15. - The index 33 is beautiful as s[33..34] == "my" and there exists an index 18 with s[18..25] == "squirrel" and |33 - 18| &lt;= 15. Thus we return [16,33] as the result.  Example 2:  Input: s = "abcd", a = "a", b = "a", k = 4 Output: [0] Explanation: There is 1 beautiful index: [0]. - The index 0 is beautiful as s[0..0] == "a" and there exists an index 0 with s[0..0] == "a" and |0 - 0| &lt;= 4. Thus we return [0] as the result.    Constraints:  1 &lt;= k &lt;= s.length &lt;= 5 <em> 105 1 &lt;= a.length, b.length &lt;= 5 </em> 105 s, a, and b contain only lowercase English letters.  </p>
</blockquote>
<p>Topics: Two Pointers, String, Binary Search, Rolling Hash, String Matching, Hash Function</p>
<h1 id="heading-problem-4-construct-quad-treehttpsleetcodecomproblemsconstruct-quad-tree">Problem #4: <a target="_blank" href="https://leetcode.com/problems/construct-quad-tree">Construct Quad Tree</a></h1>
<blockquote>
<p>Given a n * n matrix grid of 0's and 1's only. We want to represent grid with a Quad-Tree. Return the root of the Quad-Tree representing grid. A Quad-Tree is a tree data structure in which each internal node has exactly four children. Besides, each node has two attributes:  val: True if the node represents a grid of 1's or False if the node represents a grid of 0's. Notice that you can assign the val to True or False when isLeaf is False, and both are accepted in the answer. isLeaf: True if the node is a leaf node on the tree or False if the node has four children.   class Node {     public boolean val;     public boolean isLeaf;     public Node topLeft;     public Node topRight;     public Node bottomLeft;     public Node bottomRight; } We can construct a Quad-Tree from a two-dimensional area using the following steps:  If the current grid has the same value (i.e all 1's or all 0's) set isLeaf True and set val to the value of the grid and set the four children to Null and stop. If the current grid has different values, set isLeaf to False and set val to any value and divide the current grid into four sub-grids as shown in the photo. Recurse for each of the children with the proper sub-grid.   If you want to know more about the Quad-Tree, you can refer to the wiki. Quad-Tree format: You don't need to read this section for solving the problem. This is only if you want to understand the output format here. The output represents the serialized format of a Quad-Tree using level order traversal, where null signifies a path terminator where no node exists below. It is very similar to the serialization of the binary tree. The only difference is that the node is represented as a list [isLeaf, val]. If the value of isLeaf or val is True we represent it as 1 in the list [isLeaf, val] and if the value of isLeaf or val is False we represent it as 0.   Example 1:   Input: grid = [[0,1],[1,0]] Output: [[0,1],[1,0],[1,1],[1,1],[1,0]] Explanation: The explanation of this example is shown below: Notice that 0 represents False and 1 represents True in the photo representing the Quad-Tree.   Example 2:   Input: grid = [[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0],[1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1],[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0],[1,1,1,1,0,0,0,0]] Output: [[0,1],[1,1],[0,1],[1,1],[1,0],null,null,null,null,[1,0],[1,0],[1,1],[1,1]] Explanation: All values in the grid are not the same. We divide the grid into four sub-grids. The topLeft, bottomLeft and bottomRight each has the same value. The topRight have different values so we divide it into 4 sub-grids where each has the same value. Explanation is shown in the photo below:     Constraints:  n == grid.length == grid[i].length n == 2x where 0 &lt;= x &lt;= 6  </p>
</blockquote>
<p>Topics: Array, Divide and Conquer, Tree, Matrix</p>
]]></content:encoded></item><item><title><![CDATA[Top 8 Verkada Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Verkada.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - hel...]]></description><link>https://blog.chatmagic.app/top-8-verkada-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-8-verkada-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:58 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Verkada.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-snapshot-arrayhttpsleetcodecomproblemssnapshot-array">Problem #1: <a target="_blank" href="https://leetcode.com/problems/snapshot-array">Snapshot Array</a></h1>
<blockquote>
<p>Implement a SnapshotArray that supports the following interface:  SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0. void set(index, val) sets the element at the given index to be equal to val. int snap() takes a snapshot of the array and returns the snap_id: the total number of times we called snap() minus 1. int get(index, snap_id) returns the value at the given index, at the time we took the snapshot with the given snap_id    Example 1:  Input: ["SnapshotArray","set","snap","set","get"] [[3],[0,5],[],[0,6],[0,0]] Output: [null,null,0,null,5] Explanation:  SnapshotArray snapshotArr = new SnapshotArray(3); // set the length to be 3 snapshotArr.set(0,5);  // Set array[0] = 5 snapshotArr.snap();  // Take a snapshot, return snap_id = 0 snapshotArr.set(0,6); snapshotArr.get(0,0);  // Get the value of array[0] with snap_id = 0, return 5   Constraints:  1 &lt;= length &lt;= 5 <em> 104 0 &lt;= index &lt; length 0 &lt;= val &lt;= 109 0 &lt;= snap_id &lt; (the total number of times we call snap()) At most 5 </em> 104 calls will be made to set, snap, and get.  </p>
</blockquote>
<p>Topics: Array, Hash Table, Binary Search, Design</p>
<h1 id="heading-problem-2-basic-calculator-iihttpsleetcodecomproblemsbasic-calculator-ii">Problem #2: <a target="_blank" href="https://leetcode.com/problems/basic-calculator-ii">Basic Calculator II</a></h1>
<blockquote>
<p>Given a string s which represents an expression, evaluate this expression and return its value.  The integer division should truncate toward zero. You may assume that the given expression is always valid. All intermediate results will be in the range of [-231, 231 - 1]. Note: You are not allowed to use any built-in function which evaluates strings as mathematical expressions, such as eval().   Example 1: Input: s = "3+2<em>2" Output: 7 Example 2: Input: s = " 3/2 " Output: 1 Example 3: Input: s = " 3+5 / 2 " Output: 5    Constraints:  1 &lt;= s.length &lt;= 3 </em> 105 s consists of integers and operators ('+', '-', '*', '/') separated by some number of spaces. s represents a valid expression. All the integers in the expression are non-negative integers in the range [0, 231 - 1]. The answer is guaranteed to fit in a 32-bit integer.  </p>
</blockquote>
<p>Topics: Math, String, Stack</p>
<h1 id="heading-problem-3-remove-sub-folders-from-the-filesystemhttpsleetcodecomproblemsremove-sub-folders-from-the-filesystem">Problem #3: <a target="_blank" href="https://leetcode.com/problems/remove-sub-folders-from-the-filesystem">Remove Sub-Folders from the Filesystem</a></h1>
<blockquote>
<p>Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order. If a folder[i] is located within another folder[j], it is called a sub-folder of it. A sub-folder of folder[j] must start with folder[j], followed by a "/". For example, "/a/b" is a sub-folder of "/a", but "/b" is not a sub-folder of "/a/b/c". The format of a path is one or more concatenated strings of the form: '/' followed by one or more lowercase English letters.  For example, "/leetcode" and "/leetcode/problems" are valid paths while an empty string and "/" are not.    Example 1:  Input: folder = ["/a","/a/b","/c/d","/c/d/e","/c/f"] Output: ["/a","/c/d","/c/f"] Explanation: Folders "/a/b" is a subfolder of "/a" and "/c/d/e" is inside of folder "/c/d" in our filesystem.  Example 2:  Input: folder = ["/a","/a/b/c","/a/b/d"] Output: ["/a"] Explanation: Folders "/a/b/c" and "/a/b/d" will be removed because they are subfolders of "/a".  Example 3:  Input: folder = ["/a/b/c","/a/b/ca","/a/b/d"] Output: ["/a/b/c","/a/b/ca","/a/b/d"]    Constraints:  1 &lt;= folder.length &lt;= 4 * 104 2 &lt;= folder[i].length &lt;= 100 folder[i] contains only lowercase letters and '/'. folder[i] always starts with the character '/'. Each folder name is unique.  </p>
</blockquote>
<p>Topics: Array, String, Depth-First Search, Trie</p>
<h1 id="heading-problem-4-transpose-matrixhttpsleetcodecomproblemstranspose-matrix">Problem #4: <a target="_blank" href="https://leetcode.com/problems/transpose-matrix">Transpose Matrix</a></h1>
<blockquote>
<p>Given a 2D integer array matrix, return the transpose of matrix. The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices.    Example 1:  Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [[1,4,7],[2,5,8],[3,6,9]]  Example 2:  Input: matrix = [[1,2,3],[4,5,6]] Output: [[1,4],[2,5],[3,6]]    Constraints:  m == matrix.length n == matrix[i].length 1 &lt;= m, n &lt;= 1000 1 &lt;= m * n &lt;= 105 -109 &lt;= matrix[i][j] &lt;= 109  </p>
</blockquote>
<p>Topics: Array, Matrix, Simulation</p>
<h1 id="heading-problem-5-lru-cachehttpsleetcodecomproblemslru-cache">Problem #5: <a target="_blank" href="https://leetcode.com/problems/lru-cache">LRU Cache</a></h1>
<blockquote>
<p>Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class:  LRUCache(int capacity) Initialize the LRU cache with positive size capacity. int get(int key) Return the value of the key if the key exists, otherwise return -1. void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.  The functions get and put must each run in O(1) average time complexity.   Example 1:  Input ["LRUCache", "put", "put", "get", "put", "get", "put", "get", "get", "get"] [[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]] Output [null, null, null, 1, null, -1, null, -1, 3, 4]  Explanation LRUCache lRUCache = new LRUCache(2); lRUCache.put(1, 1); // cache is {1=1} lRUCache.put(2, 2); // cache is {1=1, 2=2} lRUCache.get(1);    // return 1 lRUCache.put(3, 3); // LRU key was 2, evicts key 2, cache is {1=1, 3=3} lRUCache.get(2);    // returns -1 (not found) lRUCache.put(4, 4); // LRU key was 1, evicts key 1, cache is {4=4, 3=3} lRUCache.get(1);    // return -1 (not found) lRUCache.get(3);    // return 3 lRUCache.get(4);    // return 4    Constraints:  1 &lt;= capacity &lt;= 3000 0 &lt;= key &lt;= 104 0 &lt;= value &lt;= 105 At most 2 * 105 calls will be made to get and put.  </p>
</blockquote>
<p>Topics: Hash Table, Linked List, Design, Doubly-Linked List</p>
<h1 id="heading-problem-6-interval-list-intersectionshttpsleetcodecomproblemsinterval-list-intersections">Problem #6: <a target="_blank" href="https://leetcode.com/problems/interval-list-intersections">Interval List Intersections</a></h1>
<blockquote>
<p>You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of intervals is pairwise disjoint and in sorted order. Return the intersection of these two interval lists. A closed interval [a, b] (with a &lt;= b) denotes the set of real numbers x with a &lt;= x &lt;= b. The intersection of two closed intervals is a set of real numbers that are either empty or represented as a closed interval. For example, the intersection of [1, 3] and [2, 4] is [2, 3].   Example 1:   Input: firstList = [[0,2],[5,10],[13,23],[24,25]], secondList = [[1,5],[8,12],[15,24],[25,26]] Output: [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]  Example 2:  Input: firstList = [[1,3],[5,9]], secondList = [] Output: []    Constraints:  0 &lt;= firstList.length, secondList.length &lt;= 1000 firstList.length + secondList.length &gt;= 1 0 &lt;= starti &lt; endi &lt;= 109 endi &lt; starti+1 0 &lt;= startj &lt; endj &lt;= 109  endj &lt; startj+1  </p>
</blockquote>
<p>Topics: Array, Two Pointers, Line Sweep</p>
<h1 id="heading-problem-7-diameter-of-binary-treehttpsleetcodecomproblemsdiameter-of-binary-tree">Problem #7: <a target="_blank" href="https://leetcode.com/problems/diameter-of-binary-tree">Diameter of Binary Tree</a></h1>
<blockquote>
<p>Given the root of a binary tree, return the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. The length of a path between two nodes is represented by the number of edges between them.   Example 1:   Input: root = [1,2,3,4,5] Output: 3 Explanation: 3 is the length of the path [4,2,1,3] or [5,2,1,3].  Example 2:  Input: root = [1,2] Output: 1    Constraints:  The number of nodes in the tree is in the range [1, 104]. -100 &lt;= Node.val &lt;= 100  </p>
</blockquote>
<p>Topics: Tree, Depth-First Search, Binary Tree</p>
<h1 id="heading-problem-8-number-of-1-bitshttpsleetcodecomproblemsnumber-of-1-bits">Problem #8: <a target="_blank" href="https://leetcode.com/problems/number-of-1-bits">Number of 1 Bits</a></h1>
<blockquote>
<p>Given a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight).   Example 1:  Input: n = 11 Output: 3 Explanation: The input binary string 1011 has a total of three set bits.  Example 2:  Input: n = 128 Output: 1 Explanation: The input binary string 10000000 has a total of one set bit.  Example 3:  Input: n = 2147483645 Output: 30 Explanation: The input binary string 1111111111111111111111111111101 has a total of thirty set bits.    Constraints:  1 &lt;= n &lt;= 231 - 1    Follow up: If this function is called many times, how would you optimize it?</p>
</blockquote>
<p>Topics: Divide and Conquer, Bit Manipulation</p>
]]></content:encoded></item><item><title><![CDATA[Top 5 OpenAI Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at OpenAI.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - help...]]></description><link>https://blog.chatmagic.app/top-5-openai-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-5-openai-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:57 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at OpenAI.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-2-flatten-nested-list-iteratorhttpsleetcodecomproblemsflatten-nested-list-iterator">Problem #2: <a target="_blank" href="https://leetcode.com/problems/flatten-nested-list-iterator">Flatten Nested List Iterator</a></h1>
<blockquote>
<p>You are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator to flatten it. Implement the NestedIterator class:  NestedIterator(List nestedList) Initializes the iterator with the nested list nestedList. int next() Returns the next integer in the nested list. boolean hasNext() Returns true if there are still some integers in the nested list and false otherwise.  Your code will be tested with the following pseudocode:  initialize iterator with nestedList res = [] while iterator.hasNext()     append iterator.next() to the end of res return res  If res matches the expected flattened list, then your code will be judged as correct.   Example 1:  Input: nestedList = [[1,1],2,[1,1]] Output: [1,1,2,1,1] Explanation: By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,1,2,1,1].  Example 2:  Input: nestedList = [1,[4,[6]]] Output: [1,4,6] Explanation: By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,4,6].    Constraints:  1 &lt;= nestedList.length &lt;= 500 The values of the integers in the nested list is in the range [-106, 106].  </p>
</blockquote>
<p>Topics: Stack, Tree, Depth-First Search, Design, Queue, Iterator</p>
<h1 id="heading-problem-3-time-based-key-value-storehttpsleetcodecomproblemstime-based-key-value-store">Problem #3: <a target="_blank" href="https://leetcode.com/problems/time-based-key-value-store">Time Based Key-Value Store</a></h1>
<blockquote>
<p>Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp. Implement the TimeMap class:  TimeMap() Initializes the object of the data structure. void set(String key, String value, int timestamp) Stores the key key with the value value at the given time timestamp. String get(String key, int timestamp) Returns a value such that set was called previously, with timestamp_prev &lt;= timestamp. If there are multiple such values, it returns the value associated with the largest timestamp_prev. If there are no values, it returns "".    Example 1:  Input ["TimeMap", "set", "get", "get", "set", "get", "get"] [[], ["foo", "bar", 1], ["foo", 1], ["foo", 3], ["foo", "bar2", 4], ["foo", 4], ["foo", 5]] Output [null, null, "bar", "bar", null, "bar2", "bar2"]  Explanation TimeMap timeMap = new TimeMap(); timeMap.set("foo", "bar", 1);  // store the key "foo" and value "bar" along with timestamp = 1. timeMap.get("foo", 1);         // return "bar" timeMap.get("foo", 3);         // return "bar", since there is no value corresponding to foo at timestamp 3 and timestamp 2, then the only value is at timestamp 1 is "bar". timeMap.set("foo", "bar2", 4); // store the key "foo" and value "bar2" along with timestamp = 4. timeMap.get("foo", 4);         // return "bar2" timeMap.get("foo", 5);         // return "bar2"    Constraints:  1 &lt;= key.length, value.length &lt;= 100 key and value consist of lowercase English letters and digits. 1 &lt;= timestamp &lt;= 107 All the timestamps timestamp of set are strictly increasing. At most 2 * 105 calls will be made to set and get.  </p>
</blockquote>
<p>Topics: Hash Table, String, Binary Search, Design</p>
<h1 id="heading-problem-5-largest-local-values-in-a-matrixhttpsleetcodecomproblemslargest-local-values-in-a-matrix">Problem #5: <a target="_blank" href="https://leetcode.com/problems/largest-local-values-in-a-matrix">Largest Local Values in a Matrix</a></h1>
<blockquote>
<p>You are given an n x n integer matrix grid. Generate an integer matrix maxLocal of size (n - 2) x (n - 2) such that:  maxLocal[i][j] is equal to the largest value of the 3 x 3 matrix in grid centered around row i + 1 and column j + 1.  In other words, we want to find the largest value in every contiguous 3 x 3 matrix in grid. Return the generated matrix.   Example 1:   Input: grid = [[9,9,8,1],[5,6,2,6],[8,2,6,4],[6,2,2,2]] Output: [[9,9],[8,6]] Explanation: The diagram above shows the original matrix and the generated matrix. Notice that each value in the generated matrix corresponds to the largest value of a contiguous 3 x 3 matrix in grid. Example 2:   Input: grid = [[1,1,1,1,1],[1,1,1,1,1],[1,1,2,1,1],[1,1,1,1,1],[1,1,1,1,1]] Output: [[2,2,2],[2,2,2],[2,2,2]] Explanation: Notice that the 2 is contained within every contiguous 3 x 3 matrix in grid.    Constraints:  n == grid.length == grid[i].length 3 &lt;= n &lt;= 100 1 &lt;= grid[i][j] &lt;= 100  </p>
</blockquote>
<p>Topics: Array, Matrix</p>
]]></content:encoded></item><item><title><![CDATA[Top 2 Fortinet Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Fortinet.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - he...]]></description><link>https://blog.chatmagic.app/top-2-fortinet-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-2-fortinet-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:57 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Fortinet.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-percentage-of-users-attended-a-contesthttpsleetcodecomproblemspercentage-of-users-attended-a-contest">Problem #1: <a target="_blank" href="https://leetcode.com/problems/percentage-of-users-attended-a-contest">Percentage of Users Attended a Contest</a></h1>
<blockquote>
<p>Table: Users  +-------------+---------+ | Column Name | Type    | +-------------+---------+ | user_id     | int     | | user_name   | varchar | +-------------+---------+ user_id is the primary key (column with unique values) for this table. Each row of this table contains the name and the id of a user.    Table: Register  +-------------+---------+ | Column Name | Type    | +-------------+---------+ | contest_id  | int     | | user_id     | int     | +-------------+---------+ (contest_id, user_id) is the primary key (combination of columns with unique values) for this table. Each row of this table contains the id of a user and the contest they registered into.    Write a solution to find the percentage of the users registered in each contest rounded to two decimals. Return the result table ordered by percentage in descending order. In case of a tie, order it by contest_id in ascending order. The result format is in the following example.   Example 1:  Input:  Users table: +---------+-----------+ | user_id | user_name | +---------+-----------+ | 6       | Alice     | | 2       | Bob       | | 7       | Alex      | +---------+-----------+ Register table: +------------+---------+ | contest_id | user_id | +------------+---------+ | 215        | 6       | | 209        | 2       | | 208        | 2       | | 210        | 6       | | 208        | 6       | | 209        | 7       | | 209        | 6       | | 215        | 7       | | 208        | 7       | | 210        | 2       | | 207        | 2       | | 210        | 7       | +------------+---------+ Output:  +------------+------------+ | contest_id | percentage | +------------+------------+ | 208        | 100.0      | | 209        | 100.0      | | 210        | 100.0      | | 215        | 66.67      | | 207        | 33.33      | +------------+------------+ Explanation:  All the users registered in contests 208, 209, and 210. The percentage is 100% and we sort them in the answer table by contest_id in ascending order. Alice and Alex registered in contest 215 and the percentage is ((2/3) <em> 100) = 66.67% Bob registered in contest 207 and the percentage is ((1/3) </em> 100) = 33.33%  </p>
</blockquote>
<p>Topics: Database</p>
<h1 id="heading-problem-2-number-of-ways-to-paint-n-3-gridhttpsleetcodecomproblemsnumber-of-ways-to-paint-n-3-grid">Problem #2: <a target="_blank" href="https://leetcode.com/problems/number-of-ways-to-paint-n-3-grid">Number of Ways to Paint N × 3 Grid</a></h1>
<blockquote>
<p>You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color). Given n the number of rows of the grid, return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 109 + 7.   Example 1:   Input: n = 1 Output: 12 Explanation: There are 12 possible way to paint the grid as shown.  Example 2:  Input: n = 5000 Output: 30228214    Constraints:  n == grid.length 1 &lt;= n &lt;= 5000  </p>
</blockquote>
<p>Topics: Dynamic Programming</p>
]]></content:encoded></item><item><title><![CDATA[Top 5 Rubrik Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Rubrik.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - help...]]></description><link>https://blog.chatmagic.app/top-5-rubrik-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-5-rubrik-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:57 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Rubrik.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-maximize-subarray-sum-after-removing-all-occurrences-of-one-elementhttpsleetcodecomproblemsmaximize-subarray-sum-after-removing-all-occurrences-of-one-element">Problem #1: <a target="_blank" href="https://leetcode.com/problems/maximize-subarray-sum-after-removing-all-occurrences-of-one-element">Maximize Subarray Sum After Removing All Occurrences of One Element</a></h1>
<blockquote>
<p>You are given an integer array nums. You can do the following operation on the array at most once:  Choose any integer x such that nums remains non-empty on removing all occurrences of x. Remove all occurrences of x from the array.  Return the maximum subarray sum across all possible resulting arrays.   Example 1:  Input: nums = [-3,2,-2,-1,3,-2,3] Output: 7 Explanation: We can have the following arrays after at most one operation:  The original array is nums = [-3, 2, -2, -1, 3, -2, 3]. The maximum subarray sum is 3 + (-2) + 3 = 4. Deleting all occurences of x = -3 results in nums = [2, -2, -1, 3, -2, 3]. The maximum subarray sum is 3 + (-2) + 3 = 4. Deleting all occurences of x = -2 results in nums = [-3, 2, -1, 3, 3]. The maximum subarray sum is 2 + (-1) + 3 + 3 = 7. Deleting all occurences of x = -1 results in nums = [-3, 2, -2, 3, -2, 3]. The maximum subarray sum is 3 + (-2) + 3 = 4. Deleting all occurences of x = 3 results in nums = [-3, 2, -2, -1, -2]. The maximum subarray sum is 2.  The output is max(4, 4, 7, 4, 2) = 7.  Example 2:  Input: nums = [1,2,3,4] Output: 10 Explanation: It is optimal to not perform any operations.    Constraints:  1 &lt;= nums.length &lt;= 105 -106 &lt;= nums[i] &lt;= 106  </p>
</blockquote>
<p>Topics: Array, Dynamic Programming, Segment Tree</p>
<h1 id="heading-problem-2-manhattan-distances-of-all-arrangements-of-pieceshttpsleetcodecomproblemsmanhattan-distances-of-all-arrangements-of-pieces">Problem #2: <a target="_blank" href="https://leetcode.com/problems/manhattan-distances-of-all-arrangements-of-pieces">Manhattan Distances of All Arrangements of Pieces</a></h1>
<blockquote>
<p>You are given three integers m, n, and k. There is a rectangular grid of size m × n containing k identical pieces. Return the sum of Manhattan distances between every pair of pieces over all valid arrangements of pieces. A valid arrangement is a placement of all k pieces on the grid with at most one piece per cell. Since the answer may be very large, return it modulo 109 + 7. The Manhattan Distance between two cells (xi, yi) and (xj, yj) is |xi - xj| + |yi - yj|.   Example 1:  Input: m = 2, n = 2, k = 2 Output: 8 Explanation: The valid arrangements of pieces on the board are:   In the first 4 arrangements, the Manhattan distance between the two pieces is 1. In the last 2 arrangements, the Manhattan distance between the two pieces is 2.  Thus, the total Manhattan distance across all valid arrangements is 1 + 1 + 1 + 1 + 2 + 2 = 8.  Example 2:  Input: m = 1, n = 4, k = 3 Output: 20 Explanation: The valid arrangements of pieces on the board are:   The first and last arrangements have a total Manhattan distance of 1 + 1 + 2 = 4. The middle two arrangements have a total Manhattan distance of 1 + 2 + 3 = 6.  The total Manhattan distance between all pairs of pieces across all arrangements is 4 + 6 + 6 + 4 = 20.    Constraints:  1 &lt;= m, n &lt;= 105 2 &lt;= m <em> n &lt;= 105 2 &lt;= k &lt;= m </em> n  </p>
</blockquote>
<p>Topics: Math, Combinatorics</p>
<h1 id="heading-problem-3-4sumhttpsleetcodecomproblems4sum">Problem #3: <a target="_blank" href="https://leetcode.com/problems/4sum">4Sum</a></h1>
<blockquote>
<p>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:  0 &lt;= a, b, c, d &lt; n a, b, c, and d are distinct. nums[a] + nums[b] + nums[c] + nums[d] == target  You may return the answer in any order.   Example 1:  Input: nums = [1,0,-1,0,-2,2], target = 0 Output: [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]]  Example 2:  Input: nums = [2,2,2,2,2], target = 8 Output: [[2,2,2,2]]    Constraints:  1 &lt;= nums.length &lt;= 200 -109 &lt;= nums[i] &lt;= 109 -109 &lt;= target &lt;= 109  </p>
</blockquote>
<p>Topics: Array, Two Pointers, Sorting</p>
<h1 id="heading-problem-4-insert-delete-getrandom-o1httpsleetcodecomproblemsinsert-delete-getrandom-o1">Problem #4: <a target="_blank" href="https://leetcode.com/problems/insert-delete-getrandom-o1">Insert Delete GetRandom O(1)</a></h1>
<blockquote>
<p>Implement the RandomizedSet class:  RandomizedSet() Initializes the RandomizedSet object. bool insert(int val) Inserts an item val into the set if not present. Returns true if the item was not present, false otherwise. bool remove(int val) Removes an item val from the set if present. Returns true if the item was present, false otherwise. int getRandom() Returns a random element from the current set of elements (it's guaranteed that at least one element exists when this method is called). Each element must have the same probability of being returned.  You must implement the functions of the class such that each function works in average O(1) time complexity.   Example 1:  Input ["RandomizedSet", "insert", "remove", "insert", "getRandom", "remove", "insert", "getRandom"] [[], [1], [2], [2], [], [1], [2], []] Output [null, true, false, true, 2, true, false, 2]  Explanation RandomizedSet randomizedSet = new RandomizedSet(); randomizedSet.insert(1); // Inserts 1 to the set. Returns true as 1 was inserted successfully. randomizedSet.remove(2); // Returns false as 2 does not exist in the set. randomizedSet.insert(2); // Inserts 2 to the set, returns true. Set now contains [1,2]. randomizedSet.getRandom(); // getRandom() should return either 1 or 2 randomly. randomizedSet.remove(1); // Removes 1 from the set, returns true. Set now contains [2]. randomizedSet.insert(2); // 2 was already in the set, so return false. randomizedSet.getRandom(); // Since 2 is the only number in the set, getRandom() will always return 2.    Constraints:  -231 &lt;= val &lt;= 231 - 1 At most 2 * 105 calls will be made to insert, remove, and getRandom. There will be at least one element in the data structure when getRandom is called.  </p>
</blockquote>
<p>Topics: Array, Hash Table, Math, Design, Randomized</p>
<h1 id="heading-problem-5-stamping-the-gridhttpsleetcodecomproblemsstamping-the-grid">Problem #5: <a target="_blank" href="https://leetcode.com/problems/stamping-the-grid">Stamping the Grid</a></h1>
<blockquote>
<p>You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied). You are then given stamps of size stampHeight x stampWidth. We want to fit the stamps such that they follow the given restrictions and requirements:  Cover all the empty cells. Do not cover any of the occupied cells. We can put as many stamps as we want. Stamps can overlap with each other. Stamps are not allowed to be rotated. Stamps must stay completely inside the grid.  Return true if it is possible to fit the stamps while following the given restrictions and requirements. Otherwise, return false.   Example 1:   Input: grid = [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3 Output: true Explanation: We have two overlapping stamps (labeled 1 and 2 in the image) that are able to cover all the empty cells.  Example 2:   Input: grid = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2  Output: false  Explanation: There is no way to fit the stamps onto all the empty cells without the stamps going outside the grid.    Constraints:  m == grid.length n == grid[r].length 1 &lt;= m, n &lt;= 105 1 &lt;= m <em> n &lt;= 2 </em> 105 grid[r][c] is either 0 or 1. 1 &lt;= stampHeight, stampWidth &lt;= 105  </p>
</blockquote>
<p>Topics: Array, Greedy, Matrix, Prefix Sum</p>
]]></content:encoded></item><item><title><![CDATA[Top  Softwire Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Softwire.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - he...]]></description><link>https://blog.chatmagic.app/top-softwire-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-softwire-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:57 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Softwire.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-longest-palindromic-substringhttpsleetcodecomproblemslongest-palindromic-substring">Problem #1: <a target="_blank" href="https://leetcode.com/problems/longest-palindromic-substring">Longest Palindromic Substring</a></h1>
<blockquote>
<p>Given a string s, return the longest palindromic substring in s.   Example 1:  Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer.  Example 2:  Input: s = "cbbd" Output: "bb"    Constraints:  1 &lt;= s.length &lt;= 1000 s consist of only digits and English letters.  </p>
</blockquote>
<p>Topics: Two Pointers, String, Dynamic Programming</p>
]]></content:encoded></item><item><title><![CDATA[Top 6 Myntra Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Myntra.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - help...]]></description><link>https://blog.chatmagic.app/top-6-myntra-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-6-myntra-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:57 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Myntra.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-largest-rectangle-in-histogramhttpsleetcodecomproblemslargest-rectangle-in-histogram">Problem #1: <a target="_blank" href="https://leetcode.com/problems/largest-rectangle-in-histogram">Largest Rectangle in Histogram</a></h1>
<blockquote>
<p>Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.   Example 1:   Input: heights = [2,1,5,6,2,3] Output: 10 Explanation: The above is a histogram where width of each bar is 1. The largest rectangle is shown in the red area, which has an area = 10 units.  Example 2:   Input: heights = [2,4] Output: 4    Constraints:  1 &lt;= heights.length &lt;= 105 0 &lt;= heights[i] &lt;= 104  </p>
</blockquote>
<p>Topics: Array, Stack, Monotonic Stack</p>
<h1 id="heading-problem-2-first-missing-positivehttpsleetcodecomproblemsfirst-missing-positive">Problem #2: <a target="_blank" href="https://leetcode.com/problems/first-missing-positive">First Missing Positive</a></h1>
<blockquote>
<p>Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums. You must implement an algorithm that runs in O(n) time and uses O(1) auxiliary space.   Example 1:  Input: nums = [1,2,0] Output: 3 Explanation: The numbers in the range [1,2] are all in the array.  Example 2:  Input: nums = [3,4,-1,1] Output: 2 Explanation: 1 is in the array but 2 is missing.  Example 3:  Input: nums = [7,8,9,11,12] Output: 1 Explanation: The smallest positive integer 1 is missing.    Constraints:  1 &lt;= nums.length &lt;= 105 -231 &lt;= nums[i] &lt;= 231 - 1  </p>
</blockquote>
<p>Topics: Array, Hash Table</p>
<h1 id="heading-problem-4-3sumhttpsleetcodecomproblems3sum">Problem #4: <a target="_blank" href="https://leetcode.com/problems/3sum">3Sum</a></h1>
<blockquote>
<p>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. Notice that the solution set must not contain duplicate triplets.   Example 1:  Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] Explanation:  nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0. nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0. nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) = 0. The distinct triplets are [-1,0,1] and [-1,-1,2]. Notice that the order of the output and the order of the triplets does not matter.  Example 2:  Input: nums = [0,1,1] Output: [] Explanation: The only possible triplet does not sum up to 0.  Example 3:  Input: nums = [0,0,0] Output: [[0,0,0]] Explanation: The only possible triplet sums up to 0.    Constraints:  3 &lt;= nums.length &lt;= 3000 -105 &lt;= nums[i] &lt;= 105  </p>
</blockquote>
<p>Topics: Array, Two Pointers, Sorting</p>
<h1 id="heading-problem-5-target-sumhttpsleetcodecomproblemstarget-sum">Problem #5: <a target="_blank" href="https://leetcode.com/problems/target-sum">Target Sum</a></h1>
<blockquote>
<p>You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one of the symbols '+' and '-' before each integer in nums and then concatenate all the integers.  For example, if nums = [2, 1], you can add a '+' before 2 and a '-' before 1 and concatenate them to build the expression "+2-1".  Return the number of different expressions that you can build, which evaluates to target.   Example 1:  Input: nums = [1,1,1,1,1], target = 3 Output: 5 Explanation: There are 5 ways to assign symbols to make the sum of nums be target 3. -1 + 1 + 1 + 1 + 1 = 3 +1 - 1 + 1 + 1 + 1 = 3 +1 + 1 - 1 + 1 + 1 = 3 +1 + 1 + 1 - 1 + 1 = 3 +1 + 1 + 1 + 1 - 1 = 3  Example 2:  Input: nums = [1], target = 1 Output: 1    Constraints:  1 &lt;= nums.length &lt;= 20 0 &lt;= nums[i] &lt;= 1000 0 &lt;= sum(nums[i]) &lt;= 1000 -1000 &lt;= target &lt;= 1000  </p>
</blockquote>
<p>Topics: Array, Dynamic Programming, Backtracking</p>
<h1 id="heading-problem-6-minimum-moves-to-equal-array-elements-iihttpsleetcodecomproblemsminimum-moves-to-equal-array-elements-ii">Problem #6: <a target="_blank" href="https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii">Minimum Moves to Equal Array Elements II</a></h1>
<blockquote>
<p>Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. In one move, you can increment or decrement an element of the array by 1. Test cases are designed so that the answer will fit in a 32-bit integer.   Example 1:  Input: nums = [1,2,3] Output: 2 Explanation: Only two moves are needed (remember each move increments or decrements one element): [1,2,3]  =&gt;  [2,2,3]  =&gt;  [2,2,2]  Example 2:  Input: nums = [1,10,2,9] Output: 16    Constraints:  n == nums.length 1 &lt;= nums.length &lt;= 105 -109 &lt;= nums[i] &lt;= 109  </p>
</blockquote>
<p>Topics: Array, Math, Sorting</p>
]]></content:encoded></item><item><title><![CDATA[Top 3 Gusto Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Gusto.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - helpi...]]></description><link>https://blog.chatmagic.app/top-3-gusto-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-3-gusto-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:56 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Gusto.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-integer-to-english-wordshttpsleetcodecomproblemsinteger-to-english-words">Problem #1: <a target="_blank" href="https://leetcode.com/problems/integer-to-english-words">Integer to English Words</a></h1>
<blockquote>
<p>Convert a non-negative integer num to its English words representation.   Example 1:  Input: num = 123 Output: "One Hundred Twenty Three"  Example 2:  Input: num = 12345 Output: "Twelve Thousand Three Hundred Forty Five"  Example 3:  Input: num = 1234567 Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven"    Constraints:  0 &lt;= num &lt;= 231 - 1  </p>
</blockquote>
<p>Topics: Math, String, Recursion</p>
<h1 id="heading-problem-3-time-based-key-value-storehttpsleetcodecomproblemstime-based-key-value-store">Problem #3: <a target="_blank" href="https://leetcode.com/problems/time-based-key-value-store">Time Based Key-Value Store</a></h1>
<blockquote>
<p>Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp. Implement the TimeMap class:  TimeMap() Initializes the object of the data structure. void set(String key, String value, int timestamp) Stores the key key with the value value at the given time timestamp. String get(String key, int timestamp) Returns a value such that set was called previously, with timestamp_prev &lt;= timestamp. If there are multiple such values, it returns the value associated with the largest timestamp_prev. If there are no values, it returns "".    Example 1:  Input ["TimeMap", "set", "get", "get", "set", "get", "get"] [[], ["foo", "bar", 1], ["foo", 1], ["foo", 3], ["foo", "bar2", 4], ["foo", 4], ["foo", 5]] Output [null, null, "bar", "bar", null, "bar2", "bar2"]  Explanation TimeMap timeMap = new TimeMap(); timeMap.set("foo", "bar", 1);  // store the key "foo" and value "bar" along with timestamp = 1. timeMap.get("foo", 1);         // return "bar" timeMap.get("foo", 3);         // return "bar", since there is no value corresponding to foo at timestamp 3 and timestamp 2, then the only value is at timestamp 1 is "bar". timeMap.set("foo", "bar2", 4); // store the key "foo" and value "bar2" along with timestamp = 4. timeMap.get("foo", 4);         // return "bar2" timeMap.get("foo", 5);         // return "bar2"    Constraints:  1 &lt;= key.length, value.length &lt;= 100 key and value consist of lowercase English letters and digits. 1 &lt;= timestamp &lt;= 107 All the timestamps timestamp of set are strictly increasing. At most 2 * 105 calls will be made to set and get.  </p>
</blockquote>
<p>Topics: Hash Table, String, Binary Search, Design</p>
]]></content:encoded></item><item><title><![CDATA[Top 6 Zepto Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Zepto.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - helpi...]]></description><link>https://blog.chatmagic.app/top-6-zepto-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-6-zepto-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:56 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Zepto.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-longest-univalue-pathhttpsleetcodecomproblemslongest-univalue-path">Problem #1: <a target="_blank" href="https://leetcode.com/problems/longest-univalue-path">Longest Univalue Path</a></h1>
<blockquote>
<p>Given the root of a binary tree, return the length of the longest path, where each node in the path has the same value. This path may or may not pass through the root. The length of the path between two nodes is represented by the number of edges between them.   Example 1:   Input: root = [5,4,5,1,1,null,5] Output: 2 Explanation: The shown image shows that the longest path of the same value (i.e. 5).  Example 2:   Input: root = [1,4,5,4,4,null,5] Output: 2 Explanation: The shown image shows that the longest path of the same value (i.e. 4).    Constraints:  The number of nodes in the tree is in the range [0, 104]. -1000 &lt;= Node.val &lt;= 1000 The depth of the tree will not exceed 1000.  </p>
</blockquote>
<p>Topics: Tree, Depth-First Search, Binary Tree</p>
<h1 id="heading-problem-2-merge-intervalshttpsleetcodecomproblemsmerge-intervals">Problem #2: <a target="_blank" href="https://leetcode.com/problems/merge-intervals">Merge Intervals</a></h1>
<blockquote>
<p>Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.   Example 1:  Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlap, merge them into [1,6].  Example 2:  Input: intervals = [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] and [4,5] are considered overlapping.    Constraints:  1 &lt;= intervals.length &lt;= 104 intervals[i].length == 2 0 &lt;= starti &lt;= endi &lt;= 104  </p>
</blockquote>
<p>Topics: Array, Sorting</p>
<h1 id="heading-problem-3-find-peak-elementhttpsleetcodecomproblemsfind-peak-element">Problem #3: <a target="_blank" href="https://leetcode.com/problems/find-peak-element">Find Peak Element</a></h1>
<blockquote>
<p>A peak element is an element that is strictly greater than its neighbors. Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks. You may imagine that nums[-1] = nums[n] = -∞. In other words, an element is always considered to be strictly greater than a neighbor that is outside the array. You must write an algorithm that runs in O(log n) time.   Example 1:  Input: nums = [1,2,3,1] Output: 2 Explanation: 3 is a peak element and your function should return the index number 2. Example 2:  Input: nums = [1,2,1,3,5,6,4] Output: 5 Explanation: Your function can return either index number 1 where the peak element is 2, or index number 5 where the peak element is 6.   Constraints:  1 &lt;= nums.length &lt;= 1000 -231 &lt;= nums[i] &lt;= 231 - 1 nums[i] != nums[i + 1] for all valid i.  </p>
</blockquote>
<p>Topics: Array, Binary Search</p>
<h1 id="heading-problem-4-maximum-width-ramphttpsleetcodecomproblemsmaximum-width-ramp">Problem #4: <a target="_blank" href="https://leetcode.com/problems/maximum-width-ramp">Maximum Width Ramp</a></h1>
<blockquote>
<p>A ramp in an integer array nums is a pair (i, j) for which i &lt; j and nums[i] &lt;= nums[j]. The width of such a ramp is j - i. Given an integer array nums, return the maximum width of a ramp in nums. If there is no ramp in nums, return 0.   Example 1:  Input: nums = [6,0,8,2,1,5] Output: 4 Explanation: The maximum width ramp is achieved at (i, j) = (1, 5): nums[1] = 0 and nums[5] = 5.  Example 2:  Input: nums = [9,8,1,0,1,9,4,0,4,1] Output: 7 Explanation: The maximum width ramp is achieved at (i, j) = (2, 9): nums[2] = 1 and nums[9] = 1.    Constraints:  2 &lt;= nums.length &lt;= 5 <em> 104 0 &lt;= nums[i] &lt;= 5 </em> 104  </p>
</blockquote>
<p>Topics: Array, Two Pointers, Stack, Monotonic Stack</p>
<h1 id="heading-problem-5-number-of-islandshttpsleetcodecomproblemsnumber-of-islands">Problem #5: <a target="_blank" href="https://leetcode.com/problems/number-of-islands">Number of Islands</a></h1>
<blockquote>
<p>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. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.   Example 1:  Input: grid = [   ["1","1","1","1","0"],   ["1","1","0","1","0"],   ["1","1","0","0","0"],   ["0","0","0","0","0"] ] Output: 1  Example 2:  Input: grid = [   ["1","1","0","0","0"],   ["1","1","0","0","0"],   ["0","0","1","0","0"],   ["0","0","0","1","1"] ] Output: 3    Constraints:  m == grid.length n == grid[i].length 1 &lt;= m, n &lt;= 300 grid[i][j] is '0' or '1'.  </p>
</blockquote>
<p>Topics: Array, Depth-First Search, Breadth-First Search, Union Find, Matrix</p>
<h1 id="heading-problem-6-sliding-window-maximumhttpsleetcodecomproblemssliding-window-maximum">Problem #6: <a target="_blank" href="https://leetcode.com/problems/sliding-window-maximum">Sliding Window Maximum</a></h1>
<blockquote>
<p>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 the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.   Example 1:  Input: nums = [1,3,-1,-3,5,3,6,7], k = 3 Output: [3,3,5,5,6,7] Explanation:  Window position                Max ---------------               ----- [1  3  -1] -3  5  3  6  7       3  1 [3  -1  -3] 5  3  6  7       3  1  3 [-1  -3  5] 3  6  7       5  1  3  -1 [-3  5  3] 6  7       5  1  3  -1  -3 [5  3  6] 7       6  1  3  -1  -3  5 [3  6  7]      7  Example 2:  Input: nums = [1], k = 1 Output: [1]    Constraints:  1 &lt;= nums.length &lt;= 105 -104 &lt;= nums[i] &lt;= 104 1 &lt;= k &lt;= nums.length  </p>
</blockquote>
<p>Topics: Array, Queue, Sliding Window, Heap (Priority Queue), Monotonic Queue</p>
]]></content:encoded></item><item><title><![CDATA[Top  Amdocs Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Amdocs.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - help...]]></description><link>https://blog.chatmagic.app/top-amdocs-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-amdocs-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:56 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Amdocs.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
]]></content:encoded></item><item><title><![CDATA[Top  carwale Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at carwale.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - hel...]]></description><link>https://blog.chatmagic.app/top-carwale-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-carwale-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:56 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at carwale.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-find-mirror-score-of-a-stringhttpsleetcodecomproblemsfind-mirror-score-of-a-string">Problem #1: <a target="_blank" href="https://leetcode.com/problems/find-mirror-score-of-a-string">Find Mirror Score of a String</a></h1>
<blockquote>
<p>You are given a string s. We define the mirror of a letter in the English alphabet as its corresponding letter when the alphabet is reversed. For example, the mirror of 'a' is 'z', and the mirror of 'y' is 'b'. Initially, all characters in the string s are unmarked. You start with a score of 0, and you perform the following process on the string s:  Iterate through the string from left to right. At each index i, find the closest unmarked index j such that j &lt; i and s[j] is the mirror of s[i]. Then, mark both indices i and j, and add the value i - j to the total score. If no such index j exists for the index i, move on to the next index without making any changes.  Return the total score at the end of the process.   Example 1:  Input: s = "aczzx" Output: 5 Explanation:  i = 0. There is no index j that satisfies the conditions, so we skip. i = 1. There is no index j that satisfies the conditions, so we skip. i = 2. The closest index j that satisfies the conditions is j = 0, so we mark both indices 0 and 2, and then add 2 - 0 = 2 to the score. i = 3. There is no index j that satisfies the conditions, so we skip. i = 4. The closest index j that satisfies the conditions is j = 1, so we mark both indices 1 and 4, and then add 4 - 1 = 3 to the score.   Example 2:  Input: s = "abcdef" Output: 0 Explanation: For each index i, there is no index j that satisfies the conditions.    Constraints:  1 &lt;= s.length &lt;= 105 s consists only of lowercase English letters.  </p>
</blockquote>
<p>Topics: Hash Table, String, Stack, Simulation</p>
]]></content:encoded></item><item><title><![CDATA[Top 2 KLA Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at KLA.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - helping...]]></description><link>https://blog.chatmagic.app/top-2-kla-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-2-kla-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:55 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at KLA.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-lru-cachehttpsleetcodecomproblemslru-cache">Problem #1: <a target="_blank" href="https://leetcode.com/problems/lru-cache">LRU Cache</a></h1>
<blockquote>
<p>Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class:  LRUCache(int capacity) Initialize the LRU cache with positive size capacity. int get(int key) Return the value of the key if the key exists, otherwise return -1. void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.  The functions get and put must each run in O(1) average time complexity.   Example 1:  Input ["LRUCache", "put", "put", "get", "put", "get", "put", "get", "get", "get"] [[2], [1, 1], [2, 2], [1], [3, 3], [2], [4, 4], [1], [3], [4]] Output [null, null, null, 1, null, -1, null, -1, 3, 4]  Explanation LRUCache lRUCache = new LRUCache(2); lRUCache.put(1, 1); // cache is {1=1} lRUCache.put(2, 2); // cache is {1=1, 2=2} lRUCache.get(1);    // return 1 lRUCache.put(3, 3); // LRU key was 2, evicts key 2, cache is {1=1, 3=3} lRUCache.get(2);    // returns -1 (not found) lRUCache.put(4, 4); // LRU key was 1, evicts key 1, cache is {4=4, 3=3} lRUCache.get(1);    // return -1 (not found) lRUCache.get(3);    // return 3 lRUCache.get(4);    // return 4    Constraints:  1 &lt;= capacity &lt;= 3000 0 &lt;= key &lt;= 104 0 &lt;= value &lt;= 105 At most 2 * 105 calls will be made to get and put.  </p>
</blockquote>
<p>Topics: Hash Table, Linked List, Design, Doubly-Linked List</p>
<h1 id="heading-problem-2-two-sumhttpsleetcodecomproblemstwo-sum">Problem #2: <a target="_blank" href="https://leetcode.com/problems/two-sum">Two Sum</a></h1>
<blockquote>
<p>Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.   Example 1:  Input: nums = [2,7,11,15], target = 9 Output: [0,1] Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].  Example 2:  Input: nums = [3,2,4], target = 6 Output: [1,2]  Example 3:  Input: nums = [3,3], target = 6 Output: [0,1]    Constraints:  2 &lt;= nums.length &lt;= 104 -109 &lt;= nums[i] &lt;= 109 -109 &lt;= target &lt;= 109 Only one valid answer exists.    Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity?</p>
</blockquote>
<p>Topics: Array, Hash Table</p>
]]></content:encoded></item><item><title><![CDATA[Top  Asana Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Asana.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - helpi...]]></description><link>https://blog.chatmagic.app/top-asana-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-asana-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:55 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Asana.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-product-of-array-except-selfhttpsleetcodecomproblemsproduct-of-array-except-self">Problem #1: <a target="_blank" href="https://leetcode.com/problems/product-of-array-except-self">Product of Array Except Self</a></h1>
<blockquote>
<p>Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation.   Example 1: Input: nums = [1,2,3,4] Output: [24,12,8,6] Example 2: Input: nums = [-1,1,0,-3,3] Output: [0,0,9,0,0]    Constraints:  2 &lt;= nums.length &lt;= 105 -30 &lt;= nums[i] &lt;= 30 The input is generated such that answer[i] is guaranteed to fit in a 32-bit integer.    Follow up: Can you solve the problem in O(1) extra space complexity? (The output array does not count as extra space for space complexity analysis.) </p>
</blockquote>
<p>Topics: Array, Prefix Sum</p>
]]></content:encoded></item><item><title><![CDATA[Top 2 Aon Coding Interview Questions from 2025]]></title><description><![CDATA[Introduction
In this blog post, we'll share the most commonly asked coding interview questions at Aon.  If you don't have months to study for your interviews, you can use AI tools like Chatmagic to generate solutions quickly and efficiently - helping...]]></description><link>https://blog.chatmagic.app/top-2-aon-coding-interview-questions-from-2025</link><guid isPermaLink="true">https://blog.chatmagic.app/top-2-aon-coding-interview-questions-from-2025</guid><dc:creator><![CDATA[Martin Stevenson]]></dc:creator><pubDate>Sun, 06 Apr 2025 18:07:55 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In this blog post, we'll share the most commonly asked coding interview questions at Aon.  If you don't have months to study for your interviews, you can use AI tools like <a target="_blank" href="https://www.chatmagic.app">Chatmagic</a> to generate solutions quickly and efficiently - helping you pass the interviews and get the job offer!</p>
<h1 id="heading-problem-1-construct-the-minimum-bitwise-array-iihttpsleetcodecomproblemsconstruct-the-minimum-bitwise-array-ii">Problem #1: <a target="_blank" href="https://leetcode.com/problems/construct-the-minimum-bitwise-array-ii">Construct the Minimum Bitwise Array II</a></h1>
<blockquote>
<p>You are given an array nums consisting of n prime integers. You need to construct an array ans of length n, such that, for each index i, the bitwise OR of ans[i] and ans[i] + 1 is equal to nums[i], i.e. ans[i] OR (ans[i] + 1) == nums[i]. Additionally, you must minimize each value of ans[i] in the resulting array. If it is not possible to find such a value for ans[i] that satisfies the condition, then set ans[i] = -1.   Example 1:  Input: nums = [2,3,5,7] Output: [-1,1,4,3] Explanation:  For i = 0, as there is no value for ans[0] that satisfies ans[0] OR (ans[0] + 1) = 2, so ans[0] = -1. For i = 1, the smallest ans[1] that satisfies ans[1] OR (ans[1] + 1) = 3 is 1, because 1 OR (1 + 1) = 3. For i = 2, the smallest ans[2] that satisfies ans[2] OR (ans[2] + 1) = 5 is 4, because 4 OR (4 + 1) = 5. For i = 3, the smallest ans[3] that satisfies ans[3] OR (ans[3] + 1) = 7 is 3, because 3 OR (3 + 1) = 7.   Example 2:  Input: nums = [11,13,31] Output: [9,12,15] Explanation:  For i = 0, the smallest ans[0] that satisfies ans[0] OR (ans[0] + 1) = 11 is 9, because 9 OR (9 + 1) = 11. For i = 1, the smallest ans[1] that satisfies ans[1] OR (ans[1] + 1) = 13 is 12, because 12 OR (12 + 1) = 13. For i = 2, the smallest ans[2] that satisfies ans[2] OR (ans[2] + 1) = 31 is 15, because 15 OR (15 + 1) = 31.     Constraints:  1 &lt;= nums.length &lt;= 100 2 &lt;= nums[i] &lt;= 109 nums[i] is a prime number.  </p>
</blockquote>
<p>Topics: Array, Bit Manipulation</p>
<h1 id="heading-problem-2-construct-the-minimum-bitwise-array-ihttpsleetcodecomproblemsconstruct-the-minimum-bitwise-array-i">Problem #2: <a target="_blank" href="https://leetcode.com/problems/construct-the-minimum-bitwise-array-i">Construct the Minimum Bitwise Array I</a></h1>
<blockquote>
<p>You are given an array nums consisting of n prime integers. You need to construct an array ans of length n, such that, for each index i, the bitwise OR of ans[i] and ans[i] + 1 is equal to nums[i], i.e. ans[i] OR (ans[i] + 1) == nums[i]. Additionally, you must minimize each value of ans[i] in the resulting array. If it is not possible to find such a value for ans[i] that satisfies the condition, then set ans[i] = -1.   Example 1:  Input: nums = [2,3,5,7] Output: [-1,1,4,3] Explanation:  For i = 0, as there is no value for ans[0] that satisfies ans[0] OR (ans[0] + 1) = 2, so ans[0] = -1. For i = 1, the smallest ans[1] that satisfies ans[1] OR (ans[1] + 1) = 3 is 1, because 1 OR (1 + 1) = 3. For i = 2, the smallest ans[2] that satisfies ans[2] OR (ans[2] + 1) = 5 is 4, because 4 OR (4 + 1) = 5. For i = 3, the smallest ans[3] that satisfies ans[3] OR (ans[3] + 1) = 7 is 3, because 3 OR (3 + 1) = 7.   Example 2:  Input: nums = [11,13,31] Output: [9,12,15] Explanation:  For i = 0, the smallest ans[0] that satisfies ans[0] OR (ans[0] + 1) = 11 is 9, because 9 OR (9 + 1) = 11. For i = 1, the smallest ans[1] that satisfies ans[1] OR (ans[1] + 1) = 13 is 12, because 12 OR (12 + 1) = 13. For i = 2, the smallest ans[2] that satisfies ans[2] OR (ans[2] + 1) = 31 is 15, because 15 OR (15 + 1) = 31.     Constraints:  1 &lt;= nums.length &lt;= 100 2 &lt;= nums[i] &lt;= 1000 nums[i] is a prime number.  </p>
</blockquote>
<p>Topics: Array, Bit Manipulation</p>
]]></content:encoded></item></channel></rss>