Move Zeroes at the end of array

Problem Given an integer array nums, move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. Examples Example 1: Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0] Example 2: Input: nums = [0] Output: [0] ...

Remove duplicates from Sorted Array 1

Problem Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Note that even though we want you to return the new length, make sure to change the original array as well in place. ...

Remove Element Problem

Problem Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The relative order of the elements may be changed. Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the first part of the array nums. More formally, if there are k elements after removing the duplicates, then the first k elements of nums should hold the final result. It does not matter what you leave beyond the first k elements. ...

Find frequency of a word in a book

Problem Design a method to find the frequency of occurrences of any given word in a book. Examples Example 1: Input: BookFrequency(String text) text = the day is sunny the the the sunny is is Input: getFrequency("the") Output: 4 Input: getFrequency("is") Output: 3 ...

Remove duplicates from Sorted List 2

Problem Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well. Examples Example 1: Input: head = [1,2,3,3,4,4,5] Output: [1,2,5] ...

Search Insert Position in sorted array

Problem Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. You must write an algorithm with O(log n) runtime complexity. Examples Example 1: Input: nums = [1,3,5,6], target = 5 Output: 2 ...

First Unique Character in a String

Find First Unique Character in a String Problem Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Examples Example 1: Input: s = "leetcode" Output: 0 Example 2: Input: s = "loveleetcode" Output: 2 ...

Integer to English Words Problem

Problem Convert a non-negative integer num to its English words representation. Examples Example 1: Input: num = 123 Output: "One Hundred Twenty Three" Example 2: Input: num = 12345 Output: "Twelve Thousand Three Hundred Forty Five" Example 3: ...

Super Ugly Number Problem

Problem A super ugly number is a positive integer whose prime factors are in the array primes. Given an integer n and an array of integers primes, return the nth super ugly number. The nth super ugly number is guaranteed to fit in a 32-bit signed integer. Examples Example 1: Input: n = 12, primes = [2,7,13,19] Output: 32 Explanation: [1,2,4,7,8,13,14,16,19,26,28,32] is the sequence of the first 12 super ugly numbers given primes = [2,7,13,19]. ...

Longest Substring Without Repeating Characters Problem

Problem Given a string, find the length of the longest substring without repeating characters. Examples Example 1: Input: s = "aababcbb" Output: 3 Explanation: The longest substring without repeating characters is "abc". Example 2: Input: s = "cccc" Output: 1 Explanation: The longest substring without repeating characters is "c". ...

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