Advertisement
samimwebdev

problem solving- sliding window , Multiple pointer recursion

Jan 3rd, 2023
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. 1. Is Subsequence (leetcode)
  2. https://leetcode.com/problems/is-subsequence/
  3.  
  4. 2.Longest Palindromic Substring
  5. https://leetcode.com/problems/longest-palindromic-substring/
  6.  
  7. 3.power
  8. Write a function called power which accepts a base and an exponent. The function should return the power of the base to the exponent. This function should mimic the functionality of Math.pow() - do not worry about negative bases and exponents.
  9. // power(2,0) // 1
  10. // power(2,2) // 4
  11. // power(2,4) // 16
  12.  
  13. function power(){
  14.  
  15. }
  16.  
  17. 4.capitalizeFirst
  18. Write a recursive function called capitalizeFirst. Given an array of strings, capitalize the first letter of each string in the array.
  19. function capitalizeFirst () {
  20. // code
  21. }
  22.  
  23. // capitalizeFirst(['car','taco','banana']); // ['Car','Taco','Banana']
  24.  
  25. 5. //nestedEvenSum
  26. Write a recursive function called nestedEvenSum. Return the sum of all even numbers in an object which may contain nested objects.
  27. function nestedEvenSum () {
  28. // add whatever parameters you deem necessary - good luck!
  29. }
  30.  
  31.  
  32. const obj1 = {
  33. outer: 2,
  34. obj: {
  35. inner: 2,
  36. otherObj: {
  37. superInner: 2,
  38. notANumber: true,
  39. alsoNotANumber: "yup"
  40. }
  41. }
  42. }
  43.  
  44. const obj2 = {
  45. a: 2,
  46. b: {b: 2, bb: {b: 3, bb: {b: 2}}},
  47. c: {c: {c: 2}, cc: 'ball', ccc: 5},
  48. d: 1,
  49. e: {e: {e: 2}, ee: 'car'}
  50. };
  51.  
  52. nestedEvenSum(obj1); // 6
  53. nestedEvenSum(obj2); // 10
  54.  
  55. 6. Write a function called collectStrings which accepts an object and returns an array of all the values in the object that have a typeof string
  56. const obj = {
  57. stuff: "foo",
  58. data: {
  59. val: {
  60. thing: {
  61. info: "bar",
  62. moreInfo: {
  63. evenMoreInfo: {
  64. weMadeIt: "baz"
  65. }
  66. }
  67. }
  68. }
  69. }
  70. }
  71.  
  72. collectStrings(obj) // ["foo", "bar", "baz"])
  73.  
  74. 7. Spiral Matrix
  75. https://leetcode.com/problems/spiral-matrix/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement