Algorithms Flashcards

1
Q

Contains duplicates

A

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Two sum

A

Given an array of numbers [1, 2, 3, 4] and target int 7. Goal is to return indexes of two numbers from the array so the sum of these two would be 7.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Valid anagram

A

Given two strings ‘racecar’, ‘raceacr’. Return if these two words are annagrams.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Anagram groups

A

Given an array of strings (etc [“cat”, “hat,” “atc”]). The goal is to group them. For example in the case above it will be [[“cat”, “atc”], [“hat”]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Top K Frequent Elements

A

Given an integer array nums and an integer k, return the k most frequent elements within the array. For example: nums = [1,2,2,3,3,3], k = 2 and return [2,3]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Validate Parentheses

A

You are given a string s consisting of the following characters: ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Min stack

A

The goal is to build minimal stack functionality with one additional extra feature. This extra feature is returning minimal value in the stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Valid palindrome

A

Given a string s, return true if it is a palindrome, otherwise return false.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Merge sorted array

A

You are given two sorted arrays ([1, 2, 3, 0, 0] and [2,5]). The goal is to merge them into one (into the first), sure the new array must be sorted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Remove duplicates from sorted array

A

You are given two sorted arrays ([1, 2, 3, 0, 0] and [2,5]). The goal is to merge them into one (into the first), sure the new array must be sorted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Move zeroes

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Reverse a string

A

Write a function that reverses a string. The input string is given as an array of characters s.
You must do this by modifying the input array in-place with O(1) extra memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Squares of sorted array

A

Given an integer arraynumssorted innon-decreasingorder, returnan array ofthe squares of each numbersorted in non-decreasing order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Two Sum II (input array is sorted)

A

Given an array of integers numbers that is sorted in non-decreasing order.

Return the indices (1-indexed) of two numbers, [index1, index2], such that they add up to a given target number target and index1 < index2. Note that index1 and index2 cannot be equal, therefore you may not use the same element twice.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Invert binary tree

A

You are given the root of a binary treeroot. Invert the binary tree and return its root.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Plus one

A
17
Q

Maximum Average Subarray I

A

You are given n integers and some k value. Find k sized subarray that has maximum sum of the elements. Return this value (average)

Input: nums = [1,12,-5,-6,50,3], k = 4
Output: 12.75000

Input: nums = [5], k = 1
Output: 5.00000

18
Q

Minimum Size Subarray Sum

A

You are given an array of positive integers nums and integer target. Return shortest subarray of nums which sum of elements is greater of equal to target.

Input: target = 7, nums = [2,3,1,2,4,3]
Output: 2

Input: target = 4, nums = [1,4,4]
Output: 1

19
Q

Buy and Sell crypto

A

Given array of numbers. They represent prices of a stock. Find best time to buy and sell this stock. Return profit.

20
Q

Maximum Subarray

A

Given an array of integers nums, find the subarray with the largest sum and return the sum.

A subarray is a contiguous non-empty sequence of elements within an array.

21
Q

Maximum Number of Vowels in a substring of given length

A
22
Q

Linked list cycle

A