Hands On

Remove Element

Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val. Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the following things: Custom Judge: The judge will test your …

Remove Element Read More »

Merge Sorted Array

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a length of m + n, where the first m elements denote the …

Merge Sorted Array Read More »

Valid String

A string to be valid if all characters of the string appear the same number of times Input : aabbcc Output: valid Code

Implement Stack

1. Implement the stack 2. Get Min value in stack with o(1) 3. Improve space complexity as well Code

Palindrome

If the given input is a palindrome, Print it as it is, if not reverse the string and print. Input : abcd Output: dcba The question is hidden with the meaning of not doing complex things and understanding them clearly. Answer: whatever the input, just need to reverse the string. Code:

Sort Array Input based On Sequence

Given an array of input, print the value based on the sequence of occurrence Input :   [0,1,2,3,0,0,2,2,3,0] Output: [0,0,0,0,1,2,2,2,3,3] Code:

Scroll to Top