itsmaheshkariya / JavaAssignment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array and String Coding Questions

Tags

Java, array, string, permutation, product, matrix, rotation, substring, contiguous subarray, Google interview

Description

This repository contains solutions to five tough coding questions based on arrays and strings in Java. These questions are designed to evaluate candidates at a Google level of difficulty, and cover a range of topics including string manipulation, array sorting, and matrix manipulation.

Questions

The five questions are as follows:

  1. Given two strings, write a method to determine if one is a permutation of the other. Tags: Java, string, permutation, Google interview

  2. Write a method that takes an array of integers and returns the largest product that can be obtained by multiplying any three integers. Tags: Java, array, product, Google interview

  3. Write a program that takes a matrix of integers and rotates it by 90 degrees. Tags: Java, array, matrix, rotation, Google interview

  4. Given a string, write a program to find the longest substring that contains only unique characters. Tags: Java, string, substring, Google interview

  5. Given an array of integers, write a program to find the maximum sum of any contiguous subarray. Tags: Java, array, contiguous subarray, Google interview

  6. Given an unsorted integer array nums, return the smallest missing positive integer. You must implement an algorithm that runs in O(n) time and uses constant extra space.

  7. Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized. Return the minimized largest sum of the split. Note : A subarray is a contiguous part of the array.

  8. Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring

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

  10. Given an array of integers, rearrange the array in alternating positive and negative numbers, such that no two adjacent numbers have the same sign.

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

Solutions

The solutions to these questions are provided in Java and can be found in the src directory of this repository. The files are named according to the question they solve.

Each solution includes a brief description of the problem, as well as a commented Java implementation. The code is designed to be readable and easy to understand, but may not necessarily be the most efficient solution possible.

Running the Code

To run the code, you can simply compile the Java files and run them as you would any other Java program. For example, to run the solution to the first question, you could do the following:

Note that some of the solutions may require command-line arguments or input from standard input. Please refer to the comments in the code for more information.

Contributing

If you would like to contribute to this repository, please feel free to submit a pull request with your proposed changes. Contributions are welcome, but please ensure that your code meets the same standards of readability and correctness as the existing solutions.

License

This repository is licensed under the MIT License. See the LICENSE file for more information.

About