Tuesday, September 22, 2020

int[] and Integer[] arrays - What is the difference?

This image should help you to understand the difference:






int is a number, it's a primitive type.

Integer is an object.

When you have an array of Integers, you actually have an array of objects. Array of ints is an array of primitive types.

Since arrays are objects, they're allocated on the heap. If it's an array of ints, these ints will be allocated on the heap too, within the array.

Further adding. to this..

There is a difference at run-time.

int[] is an array of primitive int values. Integer[] is an "object" array, holding references to Integer objects.

Most important practical difference: int[] cannot hold null values.

int[] does store primitive types. And the array itself lives on the heap. However, those primitives are allocated as part of the array. They are not stored separately elsewhere on the heap. This is very similar to how a primitive field is part of an object instance: The object is on the heap, and its field is an integral part of that object (whereas for a non-primitive field, only the reference is stored inside the object and the target instance that reference points at is stored separately on the heap).


Ref : this link

Wednesday, September 2, 2020

FAANG : The Journey | Post 10 | Top 50 Google tagged questions. (With Links)

 

  1. Two Sum (https://leetcode.com/problems/two-sum)
  2. Insert Interval (https://leetcode.com/problems/insert-interval)
  3. Text Justification (https://leetcode.com/problems/text-justification)
  4. Minimum Window Substring (https://leetcode.com/problems/minimum-windowsubstring)
  5. Maximal Rectangle (https://leetcode.com/problems/maximal-rectangle)
  6. The Skyline Problem (https://leetcode.com/problems/the-skyline-problem)
  7. Maximal Square (https://leetcode.com/problems/maximal-square)
  8. Meeting Rooms II (https://leetcode.com/problems/meeting-rooms-ii)
  9. Find Median from Data Stream (https://leetcode.com/problems/find-median-from-datastream)
  10. Bulls and Cows (https://leetcode.com/problems/bulls-and-cows)
  11. Count of Smaller Numbers After Self (https://leetcode.com/problems/count-of-smallernumbers-after-self)
  12. Longest Increasing Path in a Matrix (https://leetcode.com/problems/longest-increasingpath-in-a-matrix)
  13. Longest Substring with At Most K Distinct Characters
    (https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters)
  14. Moving Average from Data Stream (https://leetcode.com/problems/moving-averagefrom-data-stream)
  15. Logger Rate Limiter (https://leetcode.com/problems/logger-rate-limiter)
  16. Design Hit Counter (https://leetcode.com/problems/design-hit-counter)
  17. Max Sum of Rectangle No Larger Than K (https://leetcode.com/problems/max-sum-ofrectangle-no-larger-than-k)
  18. Decode String (https://leetcode.com/problems/decode-string)
  19. Evaluate Division (https://leetcode.com/problems/evaluate-division)
  20. Split Array Largest Sum (https://leetcode.com/problems/split-array-largest-sum)
  21. Robot Room Cleaner (https://leetcode.com/problems/robot-room-cleaner)
  22. Random Pick with Weight (https://leetcode.com/problems/random-pick-with-weight)
  23. Subarray Sum Equals K (https://leetcode.com/problems/subarray-sum-equals-k)
  24. Longest Line of Consecutive One in Matrix (https://leetcode.com/problems/longest-lineof-consecutive-one-in-matrix)
  25. Design Search Autocomplete System (https://leetcode.com/problems/design-searchautocomplete-system)
  26. Split Array into Consecutive Subsequences (https://leetcode.com/problems/split-arrayinto-consecutive-subsequences)
  27. 24 Game (https://leetcode.com/problems/24-game)
  28. Minimum Window Subsequence (https://leetcode.com/problems/minimum-windowsubsequence)
  29. Network Delay Time (https://leetcode.com/problems/network-delay-time)
  30. Open the Lock (https://leetcode.com/problems/open-the-lock)
  31. Expressive Words (https://leetcode.com/problems/expressive-words)
  32. Find And Replace in String (https://leetcode.com/problems/find-and-replace-in-string)
  33. Guess the Word (https://leetcode.com/problems/guess-the-word)
  34. Hand of Straights (https://leetcode.com/problems/hand-of-straights)
  35. Shortest Subarray with Sum at Least K (https://leetcode.com/problems/shortestsubarray-with-sum-at-least-k)
  36. X of a Kind in a Deck of Cards (https://leetcode.com/problems/x-of-a-kind-in-a-deck-ofcards)
  37. Minimum Area Rectangle (https://leetcode.com/problems/minimum-area-rectangle)
  38. Validate Stack Sequences (https://leetcode.com/problems/validate-stack-sequences)
  39. Flip Equivalent Binary Trees (https://leetcode.com/problems/flip-equivalent-binarytrees)
  40. Minimum Domino Rotations For Equal Row (https://leetcode.com/problems/minimumdomino-rotations-for-equal-row)
  41. Longest String Chain (https://leetcode.com/problems/longest-string-chain)
  42. Shortest Way to Form String (https://leetcode.com/problems/shortest-way-to-formstring)
  43. Confusing Number II (https://leetcode.com/problems/confusing-number-ii)
  44. Delete Nodes And Return Forest (https://leetcode.com/problems/delete-nodes-andreturn-forest)
  45. Snapshot Array (https://leetcode.com/problems/snapshot-array)
  46. String Transforms Into Another String (https://leetcode.com/problems/string-transformsinto-another-string)
  47. Divide Chocolate (https://leetcode.com/problems/divide-chocolate)
  48. Divide Array in Sets of K Consecutive Numbers (https://leetcode.com/problems/dividearray-in-sets-of-k-consecutive-numbers)
  49. Minimum Distance to Type a Word Using Two Fingers
    (https://leetcode.com/problems/minimum-distance-to-type-a-word-using-two-fingers)
  50. Time Needed to Inform All Employees (https://leetcode.com/problems/time-needed-toinform-all-employees)