Rotate n x n matrix by 90 degrees

Problem You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). Another way to ask the same problem Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place? Examples Example 1: ...

Find rotation count in rotated sorted array

Problem Question : Find the minimum element in the rotated sorted array. Example Example 1: Input: nums = [5, 7, 9, 1, 3] Output: 3 Explanation: The original array was [1, 3, 5, 7, 9] rotated 3 times. ...

Find Minimum in Rotated Sorted Array 1 - No duplicates allowed

Problem Find the minimum element in the rotated sorted array. For example, the array a = [0, 1, 2, 4, 6, 8, 10] might become: [8, 10, 0, 1, 2, 4, 6] if it was rotated 2 times. [4, 6, 8, 10, 0, 1, 2] if it was rotated 4 times. Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the array [a[n-1], a[0], a[1], a[2], ..., a[n-2]]. ...

Search in Rotated Sorted Array

Problem Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., [0, 1, 2, 4, 5, 6, 7] might become [4, 5, 6, 7, 0, 1, 2]). You are given a target value to search. If found in the array return its index, otherwise return -1. You may assume no duplicate exists in the array. Follow up: what if duplicates are allowed? ...

Rotate String Problem

Problem Given two string s1 and s2 how will you check if s1 is a rotated version of s2 ? OR Assume you have a method isSubstring() which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring. OR Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy