As i loop through the numbers i check if a number exists onthemap.if it does i return true if it doesnt i and add the number to the map and continue. if there are no duplicates false is returned.
-
Time complexity:O(N)
-
Space complexity:O(N)
As i loop through the numbers i check if a number exists onthemap.if it does i return true if it doesnt i and add the number to the map and continue. if there are no duplicates false is returned.
Time complexity:O(N)
Space complexity:O(N)
A double loop is created to go through the string turned array picking each letter and then checking the other letters if they match which the current letter using the isUnique boolean value. if isUnique is true we return the index i of the string . if its not found -1 is returned.
k number frequent elements which are the i[0] values are returned.to get the max profit i check if robbing a house is better than skipping while folllowing the adjacent house rule
Time complexity:O(N)
Space complexity:O(1)
n+1 times.1 in the binary representation and add it to the ans arrayTime complexity:O(NLogN)
Space complexity:O(N)
size > n / 3 then i add the number to the results array.Time complexity: O(N^2)
Space complexity: O(N)
I created a copy of the array to be able to track the rotation of the array by k numbers.
I first thought of this
function rotate(nums: number[], k: number): void {Time complexity:O(N)
Space complexity:O(N)
I create two maps to check if the order of characters are preserved. t is used as pattern for s and s also a pattern for t. if the two patterns d not match then we return false
Time complexity: O(N)
Space complexity: O(N)