question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
difference-between-maximum-and-minimum-price-sum
BFS Solution ( not optimal but INTERESTING 🤓)
bfs-solution-not-optimal-but-interesting-9z9s
Intuition\n Describe your first thoughts on how to solve this problem. \nMain intuton is any node except leaf node have multiple incoming nodes which has starti
Swarnarup
NORMAL
2024-07-12T10:47:50.328782+00:00
2024-07-12T10:47:50.328813+00:00
5
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMain intuton is any node except leaf node have multiple incoming nodes which has starting point from a leaf node. Do multisearch BFS starting from all leaf Node. and shrink gradually towards the center of the cluster.\n\n# Approach\n<!-- ...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
Simple C++ Solution | DP on Trees
simple-c-solution-dp-on-trees-by-rj_9999-o6zz
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
rj_9999
NORMAL
2024-06-29T11:44:58.423533+00:00
2024-06-29T11:44:58.423566+00:00
31
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Array', 'Dynamic Programming', 'Tree', 'Depth-First Search', 'C++']
0
difference-between-maximum-and-minimum-price-sum
Rerooting| No multi set or TreeMap
rerooting-no-multi-set-or-treemap-by-its-nbtp
Intuition\n Describe your first thoughts on how to solve this problem. \nRerooting\n\n# Approach\n Describe your approach to solving the problem. \nGet the max
itsmejatin_s
NORMAL
2024-05-30T16:22:42.028323+00:00
2024-05-30T16:22:42.028360+00:00
5
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nRerooting\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nGet the max path value for single node in one pass using dfsDown (start from `root` = 0). At this point, the `dfsDown[root]` contains the maximum price leng...
0
0
['Java']
0
difference-between-maximum-and-minimum-price-sum
Diameter endpoints are farthest
diameter-endpoints-are-farthest-by-theab-zll7
\nfrom collections import *\n\nclass Solution:\n def BFS(self, graph, i):\n q = deque([(i, self.price[i])])\n dist = {}\n dist[i] = self
theabbie
NORMAL
2024-04-10T07:47:38.762631+00:00
2024-04-10T07:47:38.762662+00:00
5
false
```\nfrom collections import *\n\nclass Solution:\n def BFS(self, graph, i):\n q = deque([(i, self.price[i])])\n dist = {}\n dist[i] = self.price[i]\n while len(q) > 0:\n curr, d = q.pop()\n for j in graph[curr]:\n if dist.get(j, float(\'inf\')) > d + ...
0
0
['Python']
0
difference-between-maximum-and-minimum-price-sum
in-out dfs
in-out-dfs-by-yv0403-g30p
Intuition\n Describe your first thoughts on how to solve this problem. \nin-out dfs technique\n\n# Approach\n Describe your approach to solving the problem. \nt
yv0403
NORMAL
2024-04-03T16:57:33.768594+00:00
2024-04-03T16:57:33.768626+00:00
9
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nin-out dfs technique\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nthis is a technique through which we can find maximum path for all nodes in O(n)\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time com...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
Tree rerooting O(3*n)
tree-rerooting-o3n-by-penguinzzz-a3dj
Intuition\nWe need to solve it for all roots, hence tree rerooting\n\n# Approach\n1. first build max length for each subtree\n2. Now build maxlength for outside
penguinzzz
NORMAL
2024-03-18T09:44:21.962490+00:00
2024-03-18T09:44:21.962524+00:00
20
false
# Intuition\nWe need to solve it for all roots, hence tree rerooting\n\n# Approach\n1. first build max length for each subtree\n2. Now build maxlength for outside the subtree and compare both\n\n# Complexity\n- Time complexity:\n`O(n)`\n\n- Space complexity:\n`O(n)`\n\n# Code\n```\n\nclass Solution {\npublic:\n long...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
C++ DP DFS O(n) Detailed approach + comments
c-dp-dfs-on-detailed-approach-comments-b-mqab
Approach\nFor questions like this, it is best to approach with the mindset "if the path passes through the current node, what is the answer?" - in this case, th
tangd6
NORMAL
2024-03-18T04:58:56.179564+00:00
2024-03-18T04:58:56.179599+00:00
22
false
# Approach\nFor questions like this, it is best to approach with the mindset "if the path passes through the current node, what is the answer?" - in this case, the answer is the maximum path cost sum.\n\nThe key here is to realise that when you are on the node u, you are calculating all the nodes that start from some l...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
Most efficient solution using javascript
most-efficient-solution-using-javascript-bns9
\n# Code\n\n/**\n * @param {number} n\n * @param {number[][]} edges\n * @param {number[]} price\n * @return {number}\n */\nvar maxOutput = function(n, edges, pr
inovra
NORMAL
2024-03-01T07:37:12.690055+00:00
2024-03-01T07:37:12.690088+00:00
13
false
\n# Code\n```\n/**\n * @param {number} n\n * @param {number[][]} edges\n * @param {number[]} price\n * @return {number}\n */\nvar maxOutput = function(n, edges, price) {\n if (n === 1) return 0\n const graph = new Array(n).fill(null).map(_=> []);\n const visited = new Array(n).fill(false)\n\n for(const edge of edge...
0
0
['JavaScript']
0
difference-between-maximum-and-minimum-price-sum
Java O(n) solution, DFS , detailed explanation
java-on-solution-dfs-detailed-explanatio-q1ey
Definition\n+ edge node or leaf node: a node has only one edge connecting to the tree. \n+ internal node: a node has more than one edge\n# Intuition\nSuppose
jasonzhang2002
NORMAL
2024-02-04T10:19:29.125953+00:00
2024-02-04T19:26:16.858525+00:00
9
false
# Definition\n+ edge node or leaf node: a node has only one edge connecting to the tree. \n+ internal node: a node has more than one edge\n# Intuition\nSuppose a path from x to y has maximal cost.\n+ The maximal pricing is the sum of prices for all nodes in the path. \n+ The minimal pricing is the smaller price amon...
0
0
['Java']
0
difference-between-maximum-and-minimum-price-sum
2538. Difference Between Maximum and Minimum Price Sum (Python)
2538-difference-between-maximum-and-mini-pz6l
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nBefore new test cases w
Koushik_leetcode
NORMAL
2024-01-30T06:50:29.439306+00:00
2024-01-30T06:50:29.439337+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nBefore new test cases were added, the following code solves the issue:\nclass Solution(object):\n\n\xA0 \xA0 def maxOutput(self, n, edges, price):\n\n\xA0 \xA0 \xA0 \x...
0
0
['Python']
0
difference-between-maximum-and-minimum-price-sum
REROOTING using IN-OUT VECTOR
rerooting-using-in-out-vector-by-dvsingh-cbn1
Intuition\nIn vector contains the max subtree sum of a node whereas out vector contains the answer of the max path outside of the subtree passing through its pa
DVSINGH
NORMAL
2024-01-06T13:38:49.666199+00:00
2024-01-06T13:38:49.666250+00:00
11
false
# Intuition\nIn vector contains the max subtree sum of a node whereas out vector contains the answer of the max path outside of the subtree passing through its parent.\n\n\n# Code\n```\nclass Solution {\npublic:\nvector<long long> in,out;\nvector<vector<int>> adj;\nlong long dfs(int src,int par,vector<int> &price){\n ...
0
0
['Depth-First Search', 'C++']
0
difference-between-maximum-and-minimum-price-sum
One Pass O(n) Beats 100%
one-pass-on-beats-100-by-sarthakbhandari-fieh
\n\n## Intuition\nPrice of each node is positive, therefore max path cost is always leaf to leaf\nBut we will need to remove the smaller leaf, if this constrain
sarthakBhandari
NORMAL
2023-12-21T22:31:06.654208+00:00
2023-12-21T22:51:41.753074+00:00
5
false
![Screenshot from 2023-12-21 22-33-09.png](https://assets.leetcode.com/users/images/b5a1ebd8-0b53-4867-8be5-57347977bc18_1703197997.3650398.png)\n\n## Intuition\nPrice of each node is positive, therefore max path cost is always leaf to leaf\nBut we will need to remove the smaller leaf, if this constraint wasnt present ...
0
0
['Array', 'Dynamic Programming', 'Depth-First Search', 'Python']
0
difference-between-maximum-and-minimum-price-sum
Dp in trees
dp-in-trees-by-camilopalacios772-kg41
Intuition\nthe minimum path sum is not relevant more than the node itself so think about getting the maximum path for every node, the naive solution is start fo
camilopalacios772
NORMAL
2023-12-15T16:46:16.711541+00:00
2023-12-15T16:46:16.711570+00:00
25
false
# Intuition\nthe minimum path sum is not relevant more than the node itself so think about getting the maximum path for every node, the naive solution is start for every node a dfs but this takes O(n^2) time complexity, so you should think for every node how can I get the maximum path? well you can do it with a dp, no ...
0
0
['Dynamic Programming', 'Depth-First Search', 'C++']
0
difference-between-maximum-and-minimum-price-sum
Reroute DP Soulution
reroute-dp-soulution-by-samhit102-30km
Code\n\nclass Solution {\npublic:\n long long ans;\n pair<long long, long long> dp[100001];\n long long dfs(auto& graph, int cur, int parent, vector<in
samhit102
NORMAL
2023-11-19T06:23:26.934923+00:00
2023-11-19T06:23:26.934940+00:00
10
false
# Code\n```\nclass Solution {\npublic:\n long long ans;\n pair<long long, long long> dp[100001];\n long long dfs(auto& graph, int cur, int parent, vector<int>& price) {\n long long max1 = 0, max2 = 0;\n for(int child : graph[cur]) {\n if(child != parent) {\n int temp;\n ...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
✅Re rooting✅ | O(N) | Explained
re-rooting-on-explained-by-jayesh_06-qjhk
AUTHOR: JAYESH BADGUJAR\n\n\n# Code\n\nclass Solution {\npublic:\n //Using DP O(N) Solution\u2705\n long long dfs(int src,map<int,vector<int>>& mp,vector<
Jayesh_06
NORMAL
2023-09-27T15:19:45.093460+00:00
2023-09-27T15:19:45.093487+00:00
18
false
# AUTHOR: JAYESH BADGUJAR\n\n\n# Code\n```\nclass Solution {\npublic:\n //Using DP O(N) Solution\u2705\n long long dfs(int src,map<int,vector<int>>& mp,vector<int>& price,vector<long long>& dp,int par){\n long long maxi=price[src];\n for(auto it:mp[src]){\n if(it==par){\n c...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
Tree không có root
tree-khong-co-root-by-dongts-vlhw
Intuition\n Describe your first thoughts on how to solve this problem. \ndfs: t\u1EA1i m\u1ED7i node, l\u01B0u {\u0111\u01B0\u1EDDng max nh\u1EA5t t\u1EEB node
dongts
NORMAL
2023-08-31T09:09:27.617377+00:00
2023-08-31T09:09:27.617428+00:00
4
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ndfs: t\u1EA1i m\u1ED7i node, l\u01B0u {\u0111\u01B0\u1EDDng max nh\u1EA5t t\u1EEB node xu\u1ED1ng l\xE1, \u0111\u01B0\u1EDDng max nh\u1EA5t t\u1EEB root xu\u1ED1ng l\xE1 - node cu\u1ED1i}\nL\xE2y k\u1EBFt qu\u1EA3: T\u1EA1i 1 node, for c\...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
[CLEAN] IN-OUT DP | O(N) time & space
clean-in-out-dp-on-time-space-by-crimson-muge
\nclass Solution {\n int n;\n vector<vector<int>> adj;\n vector<int> p;\n vector<multiset<int>> in;\n vector<int> out;\n int res;\n void df
crimsonX
NORMAL
2023-08-29T05:50:04.373618+00:00
2023-08-29T05:50:04.373641+00:00
8
false
```\nclass Solution {\n int n;\n vector<vector<int>> adj;\n vector<int> p;\n vector<multiset<int>> in;\n vector<int> out;\n int res;\n void dfs1(int node, int par){\n in[node].insert(p[node]);\n in[node].insert(0);\n for(auto &a:adj[node]){\n if(a==par)\n ...
0
0
['Dynamic Programming', 'C']
0
difference-between-maximum-and-minimum-price-sum
Code is lengthy , problem is based on tree Diameter
code-is-lengthy-problem-is-based-on-tree-3ezx
Intuition\n Describe your first thoughts on how to solve this problem. \nTree Diameter was my approach \n\n# Approach\n Describe your approach to solving the pr
007kinshuk
NORMAL
2023-08-25T13:40:24.711871+00:00
2023-08-25T13:40:24.711888+00:00
11
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTree Diameter was my approach \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nBFS \n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n\n- Space complexity:\n<!-- Add yo...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
Intuitive || DFS || O(n) working solution
intuitive-dfs-on-working-solution-by-izu-bsi2
The code is a bit long but I have tried to explain wherever felt necessary\n\n# Code\n\nclass Solution {\n ArrayList<ArrayList<Integer>> list;\n long ans
Izuku5
NORMAL
2023-08-21T17:26:10.617706+00:00
2023-08-23T06:52:58.108666+00:00
36
false
The code is a bit long but I have tried to explain wherever felt necessary\n\n# Code\n```\nclass Solution {\n ArrayList<ArrayList<Integer>> list;\n long ans = 0;\n public long maxOutput(int n, int[][] edges, int[] price) {\n list = new ArrayList();\n for(int i=0;i<n;++i){\n list.add(ne...
0
0
['Dynamic Programming', 'Depth-First Search', 'Java']
0
difference-between-maximum-and-minimum-price-sum
Re - Rooting Tree DP solution
re-rooting-tree-dp-solution-by-anantbans-vzt1
Intuition\n Describe your first thoughts on how to solve this problem. \nThough code is readable I recommend watching Kartik Arora DP on trees playlist for prop
AnantBansal
NORMAL
2023-08-19T13:32:44.792973+00:00
2023-08-19T13:32:44.792998+00:00
35
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThough code is readable I recommend watching Kartik Arora DP on trees playlist for proper understanding and how to approach to these kind of problems!\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
C++ DFS solution, O(N)
c-dfs-solution-on-by-guccigang-izt8
Run-time is O(N), space is O(N).\n\nSome caveats: \n\n1. We only need to worry about each node\'s children, and we can pick the starting node arbitrarily. This
guccigang
NORMAL
2023-07-21T21:09:11.271432+00:00
2023-07-21T21:09:11.271460+00:00
21
false
Run-time is $$O(N)$$, space is $$O(N)$$.\n\nSome caveats: \n\n1. We only need to worry about each node\'s children, and we can pick the starting node arbitrarily. This is because the path must consists of either path from any current child to some leaf node, or from root. We can leave the root calculation once we backt...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
C++ | DP | DFS
c-dp-dfs-by-krunal_078-w456
\nclass Solution {\npublic:\n #define ll long long\n void inDfs(vector<int> adj[],int n,int node,int prev,vector<int> &price,vector<ll> &in){\n in[
krunal_078
NORMAL
2023-06-21T09:28:26.806028+00:00
2023-06-21T09:28:26.806047+00:00
34
false
```\nclass Solution {\npublic:\n #define ll long long\n void inDfs(vector<int> adj[],int n,int node,int prev,vector<int> &price,vector<ll> &in){\n in[node] = price[node];\n ll mx = 0;\n for(auto &ele:adj[node]){\n if(ele!=prev){\n inDfs(adj,n,ele,node,price,in);\n ...
0
0
['Dynamic Programming', 'Tree', 'Depth-First Search', 'C']
0
difference-between-maximum-and-minimum-price-sum
[C++] Easy to Understand O(N) Solution | Beats 96.9%
c-easy-to-understand-on-solution-beats-9-b4at
\n#define ll long long\nclass Solution {\nprivate:\n vector<vector<int>> graph;\n vector<pair<ll,ll>> mxSubtree; // {mx1, mx2} branch-wise\n ll getMaxS
_an1rudh
NORMAL
2023-06-21T08:51:52.292700+00:00
2023-06-21T08:51:52.292718+00:00
77
false
```\n#define ll long long\nclass Solution {\nprivate:\n vector<vector<int>> graph;\n vector<pair<ll,ll>> mxSubtree; // {mx1, mx2} branch-wise\n ll getMaxSubtree(int node, int par, vector<int> &price) { //dfs to get mx1,mx2 sum from all branches\n ll mx1 = 0, mx2 = 0;\n for(int &child: graph[node]...
0
0
['Tree', 'Depth-First Search', 'C++']
0
difference-between-maximum-and-minimum-price-sum
beats 80% cpp solution
beats-80-cpp-solution-by-ahethesham8-mziw
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
ahethesham8
NORMAL
2023-06-15T09:56:47.431083+00:00
2023-06-15T09:56:47.431102+00:00
34
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
reverse wavefronts| bottom up tree traversal
reverse-wavefronts-bottom-up-tree-traver-g8c1
start from all the leaves and travel inwards according to number of unvisited neighbors == 1, keeping the queue and track of visited nodes just like you would d
redsmolder
NORMAL
2023-04-25T06:11:08.422811+00:00
2023-04-25T06:11:08.422857+00:00
12
false
start from all the leaves and travel inwards according to number of unvisited neighbors == 1, keeping the queue and track of visited nodes just like you would do in BFS(naming it BFS in any way apart from use of queue would be wrong). **This is bottom up tree traversal i.e. no node is visited until all its children are...
0
0
[]
0
difference-between-maximum-and-minimum-price-sum
Both O(n) and O(nlog(n)) Solutions C++
both-on-and-onlogn-solutions-c-by-kumar_-yr9v
Complexity\n- Time complexity:\nO(nlog(n))\n\n- Space complexity:\n- O(n)\n\n# Code\n\nclass Solution {\npublic:\n vector<vector<int>>adjList ;\n long lon
Kumar_11
NORMAL
2023-03-31T04:35:47.675038+00:00
2023-03-31T04:35:47.675083+00:00
72
false
# Complexity\n- Time complexity:\nO(nlog(n))\n\n- Space complexity:\n- O(n)\n\n# Code\n```\nclass Solution {\npublic:\n vector<vector<int>>adjList ;\n long long result ;\n void ans(int source , int parent , vector<int>&price , vector<long long>&sum ){\n result = max(result , sum[source] - price[source])...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
Graph traversal, C#
graph-traversal-c-by-user4435yf-lpk4
\n\n# Complexity\n- Time complexity:\nO(n) \nEvery node gets visited exactly once during recursive solution.\n\n- Space complexity:\nO(n) for graph connectivity
user4435YF
NORMAL
2023-03-29T20:30:04.122889+00:00
2023-03-29T20:30:04.122921+00:00
24
false
\n\n# Complexity\n- Time complexity:\n$$O(n)$$ \nEvery node gets visited exactly once during recursive solution.\n\n- Space complexity:\n$$O(n)$$ for graph connectivity and also $$O(n)$$ worst-case stack requirement\n\n# Code\n```\npublic class Solution {\n public long MaxOutput(int n, int[][] edges, int[] price) {\...
0
0
['Tree', 'C#']
0
difference-between-maximum-and-minimum-price-sum
Tree Dp and Re-rooting Technique| O(N) Code (C++)
tree-dp-and-re-rooting-technique-on-code-rvq7
Intuition\nFixing the root then using re-rooting technique to find the solution for all the other roots.\n# Time Complexity\nO(n)\n# Code\n\n#define ll long lon
rahulhind
NORMAL
2023-03-21T16:28:20.165341+00:00
2023-03-21T16:28:20.165372+00:00
140
false
# Intuition\nFixing the root then using re-rooting technique to find the solution for all the other roots.\n# Time Complexity\n$$O(n)$$\n# Code\n```\n#define ll long long\nclass Solution {\npublic:\n const static int M=1e5+100;\n ll dp[M];\n void dfs(int s,int p,vector<vector<int>>&graph,vector<int>&cost){\n ...
0
0
['Dynamic Programming', 'Tree', 'Memoization', 'C++']
0
difference-between-maximum-and-minimum-price-sum
Reroot so only 2 dfs is needed instead of n dfs.
reroot-so-only-2-dfs-is-needed-instead-o-w426
Intuition\nWe can treat every node as root, and run DFS n times. But we can use re-root trick to do two DFS.\n\n# Code\n\nstruct GraphNode {\n GraphNode(int
huangdachuan
NORMAL
2023-03-13T03:42:43.940480+00:00
2023-03-13T03:42:43.940523+00:00
53
false
# Intuition\nWe can treat every node as root, and run DFS n times. But we can use re-root trick to do two DFS.\n\n# Code\n```\nstruct GraphNode {\n GraphNode(int id, int cost):\n id(id),\n cost(cost),\n neighbors(),\n maxDepth(cost),\n maxNodeId(-1),\n max2Depth(cost)\n {...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
100% working || DFS || Re-rooting Technique
100-working-dfs-re-rooting-technique-by-tknvl
Intuition\nUsing the re-rooting technique\n\nTo understand this technique visit the on this you-tube link : \n\nhttps://www.youtube.com/watch?v=N7e4CTfimkU\n\n#
gauravgoyal_13
NORMAL
2023-03-07T07:42:03.091129+00:00
2023-03-07T07:42:03.091171+00:00
84
false
# Intuition\nUsing the re-rooting technique\n\nTo understand this technique visit the on this you-tube link : \n\nhttps://www.youtube.com/watch?v=N7e4CTfimkU\n\n# Complexity\n- Time complexity: O(N)\n\n- Space complexity: O(N)\n\n** **\n**Please upvote me if it helpful for you... happy coding**\n# Code\n```\n#include<u...
0
0
['C++']
0
difference-between-maximum-and-minimum-price-sum
Deatiled description C++ easy to understand code
deatiled-description-c-easy-to-understan-gimv
\nclass Solution {\npublic:\n long long result = 0;\n // Function to compute the max sum for a given subtree across all the nodes\n long long maxSum(in
vishalrathi02
NORMAL
2023-02-15T03:15:44.342108+00:00
2023-02-15T03:15:44.342145+00:00
31
false
```\nclass Solution {\npublic:\n long long result = 0;\n // Function to compute the max sum for a given subtree across all the nodes\n long long maxSum(int from, int cur, vector<vector<int>> &adj, vector<int> &price, vector<long long> &dp) {\n long long res = 0;\n for (auto &to : adj[cur]) {\n ...
0
0
[]
0
difference-between-maximum-and-minimum-price-sum
C++ || DFS( Two DFS traversal)
c-dfs-two-dfs-traversal-by-hrithik8083-1ne6
0.\n\n# Code\n\nclass Solution {\npublic:\n void dfs2(vector<vector<int>>& adj,vector<long long>&sum,vector<int>&vis,int u,vector<int>&price,vector<long long
hrithik8083
NORMAL
2023-02-07T18:38:20.564136+00:00
2023-02-07T18:38:20.564178+00:00
122
false
0.\n\n# Code\n```\nclass Solution {\npublic:\n void dfs2(vector<vector<int>>& adj,vector<long long>&sum,vector<int>&vis,int u,vector<int>&price,vector<long long>& dist)\n {\n vis[u]=1;\n long long max1=0;\n long long max2=0;\n for(auto x:adj[u])\n {\n if(vis[x]==0)\n ...
0
0
['Depth-First Search', 'Binary Tree', 'C++']
0
difference-between-maximum-and-minimum-price-sum
O(n) Re-rooting w/ Two-Pass Bidirectional DFS • 🎨 Diagram 💬 Comments 📛 Semantic Variables
on-re-rooting-w-two-pass-bidirectional-d-0i08
Approach\nThe brute-force approach would be to calculate the max path using a DFS from each node but this results in a TLE due to the O(n * n) time complexity.
jeffcamera
NORMAL
2023-02-01T18:53:06.736393+00:00
2023-02-01T18:53:06.736428+00:00
66
false
# Approach\nThe brute-force approach would be to calculate the max path using a DFS from each node but this results in a TLE due to the O(n * n) time complexity. Instead we do two DFS passes and store two solutions for each node. This allows us to figure out the max path for each node on the second pass.\n\nIn the firs...
0
0
['Dynamic Programming', 'Depth-First Search', 'C#']
0
difference-between-maximum-and-minimum-price-sum
C++ up-to-down and down-to-up DFS
c-up-to-down-and-down-to-up-dfs-by-vvhac-brjt
Sorry my English here might not be the best.\nFirst of all, the min price path is just the node by itself.\nWe pick any root at random, let\'s say 0.\nFirst we
vvhack
NORMAL
2023-01-28T21:29:27.949090+00:00
2023-01-28T21:33:25.353445+00:00
43
false
Sorry my English here might not be the best.\nFirst of all, the min price path is just the node by itself.\nWe pick any root at random, let\'s say 0.\nFirst we get information from children and pass it up to the root (what is the maximum price path going downwards from the root) then we do another pass in which we pass...
0
0
[]
0
check-if-the-number-is-fascinating
3 lines || C++ || Easy
3-lines-c-easy-by-shrikanta8-80k2
CodeHappy Coding!Radhe Radhe😊
Shrikanta8
NORMAL
2023-06-10T16:02:00.611319+00:00
2025-02-20T19:00:10.545472+00:00
1,872
false
# Code ``` class Solution { public: bool isFascinating(int n) { string str= to_string(n)+to_string(2*n)+to_string(3*n); sort(str.begin(),str.end()); return str == "123456789"; } }; ``` **Happy Coding!** Radhe Radhe😊
22
1
['C++']
2
check-if-the-number-is-fascinating
Using set || Very simple and easy to understand solution
using-set-very-simple-and-easy-to-unders-koft
Up vote if you like the solution\n# Approach\nTake a set to check total number of uniqe char in the final string.\nIn the set check :\n- if the total unique cha
kreakEmp
NORMAL
2023-06-10T16:16:11.502409+00:00
2023-06-10T18:45:21.934249+00:00
2,682
false
<b>Up vote if you like the solution</b>\n# Approach\nTake a set to check total number of uniqe char in the final string.\nIn the set check :\n- if the total unique char count is 9\n- if the total size of the string s is 9\n- if there is no \'0\' in the string\n\n# Code\n```\nbool isFascinating(int n) {\n string s = ...
19
2
['C++']
4
check-if-the-number-is-fascinating
easy python code Beats 100% in Memory
easy-python-code-beats-100-in-memory-by-cjux8
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
hakkiot
NORMAL
2023-06-11T02:29:59.961417+00:00
2023-06-11T02:29:59.961441+00:00
717
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
17
0
['Python3']
1
check-if-the-number-is-fascinating
✅ Bits (O(1) Space)
bits-o1-space-by-xxvvpp-3shx
We just traverse all digits in all 3 numbers & use bit manipulation to check if every digit is between [1, 9].\n# C++\n bool isFascinating(int n) {\n
xxvvpp
NORMAL
2023-06-10T16:15:58.224804+00:00
2023-06-10T16:38:14.329433+00:00
1,835
false
We just traverse all digits in all `3` numbers & use `bit manipulation` to check if every digit is between `[1, 9]`.\n# C++\n bool isFascinating(int n) {\n int freq = 0;\n function<bool(int)> repd = [&](int n) {\n while(n) {\n int d = n % 10;\n if(d == 0 || (fre...
16
0
['Bit Manipulation', 'C']
5
check-if-the-number-is-fascinating
Python 3 || 2 versions || T/S: 94% / 79%
python-3-2-versions-ts-94-79-by-spauldin-u3hi
Version 1: string manipulation\n\nclass Solution:\n def isFascinating(self, n: int) -> bool: \n\n return \'\'.join(sorted(str(n) + str(2*n) + str(3*n)
Spaulding_
NORMAL
2023-06-10T17:43:13.282459+00:00
2024-06-18T17:37:29.380146+00:00
378
false
Version 1: string manipulation\n```\nclass Solution:\n def isFascinating(self, n: int) -> bool: \n\n return \'\'.join(sorted(str(n) + str(2*n) + str(3*n))) == \'123456789\'\n```\nVersion 2: Mathematics. It\'s an interesting number theory exercise to show that*:\n- a number`n`is *fascinating* only if `123 <= ...
12
0
['Python3']
2
check-if-the-number-is-fascinating
2729. Check if The Number is Fascinating, Time complexity: O(N), Space complexity: O(N)
2729-check-if-the-number-is-fascinating-o7m37
IntuitionApproachComplexity Time complexity: O(N) Space complexity: O(N) Code
richardmantikwang
NORMAL
2024-12-23T10:36:33.919274+00:00
2024-12-23T10:36:33.919274+00:00
207
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: O(N) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(N) <!-- Add your space complexity here, e.g. $$O(n)$$ -->...
10
0
['Python3']
0
check-if-the-number-is-fascinating
C++ || 2 different approaches || O(1) TC
c-2-different-approaches-o1-tc-by-heder-66ry
Approach 1: do the work at compile time\nThe property of being fascinating doesn\'t change, hence we can pre compute them at compile time. ::isFascinating is in
heder
NORMAL
2023-06-11T09:55:48.283317+00:00
2023-07-14T20:54:06.881704+00:00
982
false
# Approach 1: do the work at compile time\nThe property of being _fascinating_ doesn\'t change, hence we can pre compute them at compile time. ```::isFascinating``` is inspired by [this post](https://leetcode.com/problems/check-if-the-number-is-fascinating/discuss/3622454/Bits-(O(1)-Space)).\n\n```cpp\nnamespace {\ncon...
10
0
['C']
2
check-if-the-number-is-fascinating
Most efficient O(1)
most-efficient-o1-by-java_programmer_ket-myud
There are just 4 numbers which satisfy this condition. TC->O(1)\n\nclass Solution {\n public boolean isFascinating(int n) {\n return n == 192 || n ==
Java_Programmer_Ketan
NORMAL
2023-06-10T17:28:36.254977+00:00
2023-06-10T17:28:36.255024+00:00
1,377
false
There are just 4 numbers which satisfy this condition. TC->O(1)\n```\nclass Solution {\n public boolean isFascinating(int n) {\n return n == 192 || n == 219 || n==273 || n==327;\n }\n}\n```
9
1
['Java']
4
check-if-the-number-is-fascinating
One Liner💯 (Easiest)
one-liner-easiest-by-shehza-d-3x6s
\n # Intuition \n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nI sort the input
shehza-d
NORMAL
2023-06-10T16:13:28.651617+00:00
2023-06-10T16:27:45.130847+00:00
644
false
\n<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nI sort the input number in string and then matched with the desired outcome. \n\n# Code\n```js\nconst isFascinating = (n) => "123456789" === `${n}${n * 2}${...
7
0
['TypeScript', 'JavaScript']
0
check-if-the-number-is-fascinating
Easy and clean Solution [ Beginner Freindly] python3
easy-and-clean-solution-beginner-freindl-nitb
```\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n s = str(n)\n \n s = s + str(2n) + str(3n)\n \n ans = set(s)\
KmrVikas
NORMAL
2023-06-10T16:07:10.746140+00:00
2023-06-10T16:07:10.746183+00:00
1,642
false
```\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n s = str(n)\n \n s = s + str(2*n) + str(3*n)\n \n ans = set(s)\n\n return len(ans) == 9 == len(s) and \'0\' not in ans\n \n
6
1
[]
1
check-if-the-number-is-fascinating
3 lines easy c++ solution ✅✅
3-lines-easy-c-solution-by-te-ke_alone-ho72
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
te-ke_alone
NORMAL
2023-06-10T19:12:26.793349+00:00
2023-06-10T20:46:23.639322+00:00
385
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\nO(NlogN)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n bool isFascinating(int n) {\n \n ...
5
1
['String', 'Sorting', 'C++']
3
check-if-the-number-is-fascinating
100%,98% BEATS || C++
10098-beats-c-by-ganeshkumawat8740-tcfq
Code\n\nclass Solution {\npublic:\n bool isFascinating(int n) {\n string str = "";\n int a = n*2,b=n*3;\n str = to_string(n)+to_string(a
ganeshkumawat8740
NORMAL
2023-06-10T16:18:22.994619+00:00
2023-06-10T16:18:22.994666+00:00
1,875
false
# Code\n```\nclass Solution {\npublic:\n bool isFascinating(int n) {\n string str = "";\n int a = n*2,b=n*3;\n str = to_string(n)+to_string(a)+to_string(b);\n vector<int> v(10,0);\n for(auto &i: str){\n v[i-\'0\']++;\n }\n for(int i = 0; i < 10; i++){\n ...
5
1
['C++']
0
check-if-the-number-is-fascinating
✅ Explained - Simple and Clear Python3 Code✅
explained-simple-and-clear-python3-code-rqyz3
Intuition\nThe problem asks us to determine whether a given three-digit number is fascinating or not. To be fascinating, the number must meet certain conditions
moazmar
NORMAL
2023-06-10T16:04:19.298336+00:00
2023-06-10T16:04:19.298400+00:00
1,426
false
# Intuition\nThe problem asks us to determine whether a given three-digit number is fascinating or not. To be fascinating, the number must meet certain conditions after concatenating it with 2 * n and 3 * n. The conditions are that the resulting concatenated number should contain all digits from 1 to 9 exactly once and...
5
1
['Python3']
3
check-if-the-number-is-fascinating
easy C++ solution
easy-c-solution-by-prashant_71200-oorj
Intuition\nThe problem requires checking whether a number is fascinating or not. A fascinating number is one that, when multiplied by 2 and 3, results in a conc
prashant_71200
NORMAL
2024-01-25T10:19:29.669533+00:00
2024-01-25T10:19:29.669564+00:00
93
false
# Intuition\nThe problem requires checking whether a number is fascinating or not. A fascinating number is one that, when multiplied by 2 and 3, results in a concatenated string of the original number, double the original number, and triple the original number containing all digits from 1 to 9 exactly once.\n\n# Approa...
3
0
['C++']
0
check-if-the-number-is-fascinating
[JAVA] 100% faster solution
java-100-faster-solution-by-jugantar2020-ckrw
\n\n# Complexity\n- Time complexity: O(log n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n
Jugantar2020
NORMAL
2023-07-19T08:04:49.348697+00:00
2023-07-19T08:04:49.348719+00:00
341
false
\n\n# Complexity\n- Time complexity: O(log n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public boolean isFascinating(int n) {\n boolean[] fascinating = new boolean[10];\n ...
3
0
['Array', 'Hash Table', 'Math', 'Java']
2
check-if-the-number-is-fascinating
Java Solution || Using For Loop
java-solution-using-for-loop-by-ankur_ch-9qc1
Intuition\n Describe your first thoughts on how to solve this problem. \nWe are given a number n, we need to check whether every digit from 1 to 9 is present in
Ankur_Chhillar
NORMAL
2023-07-12T14:41:18.036875+00:00
2023-07-12T14:46:42.708062+00:00
186
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe are given a number n, we need to check whether every digit from 1 to 9 is present in the number which is formed connecting n + 2 * n + 3 * n.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIn the code we have m...
3
0
['Java']
1
check-if-the-number-is-fascinating
Simple and Easy to understand CPP solution.
simple-and-easy-to-understand-cpp-soluti-wx1m
Intuition\nThe code checks if a given number n is fascinating or not by following a specific approach. It concatenates n, 2n, and 3n, sorts the resulting string
nidhi_jat
NORMAL
2023-06-11T16:17:53.168193+00:00
2023-06-11T16:17:53.168242+00:00
535
false
# Intuition\nThe code checks if a given number n is fascinating or not by following a specific approach. It concatenates n, 2n, and 3n, sorts the resulting string, and then checks for any repeated digits or zeros. If there are any repeated digits or zeros, the number is considered not fascinating.\n\n# Approach\n- Mult...
3
1
['String', 'Sorting', 'C++']
0
check-if-the-number-is-fascinating
[C++/Java] Bitwise Operations for Efficient Digit Tracking
cjava-bitwise-operations-for-efficient-d-mbs8
We the process by concatenating n, 2*n, and 3*n. Following this, it verifies that the concatenated string\'s length is strictly 9. If not, it directly returns f
xiangcan
NORMAL
2023-06-10T18:57:40.248184+00:00
2023-06-10T19:04:10.409887+00:00
401
false
We the process by concatenating `n`, `2*n`, and `3*n`. Following this, it verifies that the concatenated string\'s length is strictly `9`. If not, it directly returns `false`, as it\'s not possible for the number to incorporate all digits from `1` to `9` individually.\n\nSubsequently, a `state` variable is defined, ini...
3
0
['C', 'Java']
0
check-if-the-number-is-fascinating
Python Elegant & Short | Counter
python-elegant-short-counter-by-kyrylo-k-ukao
Complexity\n- Time complexity: O(n)\n- Space complexity: O(n)\n\n\n# Code\n\nclass Solution:\n DIGITS = Counter(\'123456789\')\n\n def isFascinating(self,
Kyrylo-Ktl
NORMAL
2023-06-10T17:55:11.654405+00:00
2023-06-10T17:55:11.654445+00:00
400
false
# Complexity\n- Time complexity: $$O(n)$$\n- Space complexity: $$O(n)$$\n\n\n# Code\n```\nclass Solution:\n DIGITS = Counter(\'123456789\')\n\n def isFascinating(self, n: int) -> bool:\n return Counter(str(n) + str(2 * n) + str(3 * n)) == self.DIGITS\n\n```
3
0
['Hash Table', 'Python', 'Python3']
0
check-if-the-number-is-fascinating
Java easy solution
java-easy-solution-by-ydvaaman-owb2
\nclass Solution {\n public boolean isFascinating(int n) {\n String str = String.valueOf(n) + String.valueOf(2*n) + String.valueOf(3*n);\n Hash
ydvaaman
NORMAL
2023-06-10T17:15:12.412638+00:00
2023-06-10T17:15:12.412688+00:00
297
false
```\nclass Solution {\n public boolean isFascinating(int n) {\n String str = String.valueOf(n) + String.valueOf(2*n) + String.valueOf(3*n);\n HashSet<Integer> set = new HashSet<>();\n System.out.println(str);\n for(int i=0;i<str.length();i++){\n int ch = str.charAt(i)-\'0\'; ...
3
0
['Java']
3
check-if-the-number-is-fascinating
easy hai like to_string karo store karo check karo ki 1 to 9 hai by help of an arr aisa :D
easy-hai-like-to_string-karo-store-karo-iwgrv
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
yesyesem
NORMAL
2024-08-27T07:16:18.766387+00:00
2024-08-27T07:16:18.766455+00:00
76
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['C++']
0
check-if-the-number-is-fascinating
Easy Brototype javascript solution
easy-brototype-javascript-solution-by-ah-8oyu
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
ahmedrithas48
NORMAL
2024-01-21T07:44:30.634147+00:00
2024-01-21T07:44:30.634177+00:00
66
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['JavaScript']
0
check-if-the-number-is-fascinating
easy to understand JS
easy-to-understand-js-by-javad_pk-66gv
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
javad_pk
NORMAL
2024-01-19T15:54:52.633243+00:00
2024-01-19T15:54:52.633269+00:00
151
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['JavaScript']
0
check-if-the-number-is-fascinating
Simplest solution ever in python beat 90%
simplest-solution-ever-in-python-beat-90-18mk
\n\n# Code\n\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n num=str(n)+str(2*n)+str(3*n)\n for i in num:\n if num.cou
hrishikeshprasadc
NORMAL
2024-01-19T09:04:15.759510+00:00
2024-01-19T09:04:15.759546+00:00
90
false
\n\n# Code\n```\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n num=str(n)+str(2*n)+str(3*n)\n for i in num:\n if num.count(i)>1 or \'0\' in num:\n return False\n return True\n \n```
2
0
['Python', 'Python3']
0
check-if-the-number-is-fascinating
Python code to check if the number is fascinating (TC&SC: O(log(n)))
python-code-to-check-if-the-number-is-fa-1jvm
\n# Complexity\n- Time complexity:\nO(log(n))\n\n- Space complexity:\nO(log(n))\n\n# Code\n\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n
Nayandhika
NORMAL
2023-10-13T05:36:30.470428+00:00
2023-10-13T05:36:30.470459+00:00
41
false
\n# Complexity\n- Time complexity:\nO(log(n))\n\n- Space complexity:\nO(log(n))\n\n# Code\n```\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n count = 0\n z = str(n)+str(2*n)+str(3*n)\n for i in range(1,10):\n if str(i) in z:\n count = count+1\n if ...
2
0
['Python', 'Python3']
0
check-if-the-number-is-fascinating
Power of JavaScript using String Interpolation and Sorting
power-of-javascript-using-string-interpo-si3l
Complexity\n- Time complexity: O(Nlog(N))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n
gouravojha4321
NORMAL
2023-07-01T19:30:41.948690+00:00
2023-07-01T19:30:41.948707+00:00
146
false
# Complexity\n- Time complexity: O(Nlog(N))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfunction isFascinating(n: number): boolean {\n let allNumbers = \'123456789\'\n let fancyNumber = `${n}${n * 2}${n ...
2
0
['Math', 'Sorting', 'TypeScript', 'JavaScript']
0
check-if-the-number-is-fascinating
C++ Easy To Understand Solution | Using Sets
c-easy-to-understand-solution-using-sets-pjb6
Approach\n Describe your approach to solving the problem. \n\n1. Converting the number to string is first step.\n2. Adding all the characters to a set as it con
shweta0098
NORMAL
2023-06-30T03:06:49.998939+00:00
2023-06-30T03:06:49.998964+00:00
32
false
# Approach\n<!-- Describe your approach to solving the problem. -->\n\n1. Converting the number to string is first step.\n2. Adding all the characters to a set as it contains only unique characters.\n3. The size of string and set must be exactly equal to 9 i.e. it contains all the digits from 1 to 9 exactly once.\n4. L...
2
0
['C++']
0
check-if-the-number-is-fascinating
C++ Easy Solution ✅✅
c-easy-solution-by-shubhamjain287-kxks
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Shubhamjain287
NORMAL
2023-06-29T06:49:32.187548+00:00
2023-06-29T06:49:32.187575+00:00
246
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['C++']
0
check-if-the-number-is-fascinating
Easy Python Solution
easy-python-solution-by-vistrit-wqpv
Code\n\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n s=str(n)+str(n*2)+str(n*3)\n k="123456789"\n return set(s)==set(k)
vistrit
NORMAL
2023-06-27T18:28:23.039559+00:00
2023-06-27T18:28:23.039593+00:00
306
false
# Code\n```\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n s=str(n)+str(n*2)+str(n*3)\n k="123456789"\n return set(s)==set(k) and len(s)==9\n```
2
0
['Python3']
0
check-if-the-number-is-fascinating
Beginners Approach
beginners-approach-by-bhaskarkumar07-53bw
\n# Complexity\n- Time complexity:O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(N)\n Add your space complexity here, e.g. O(n) \n\n#
bhaskarkumar07
NORMAL
2023-06-22T06:22:02.391433+00:00
2023-06-22T06:22:02.391464+00:00
429
false
\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public boolean isFascinating(int n) {\n String res= (n)+""+(n*2)+""+(n*3);\n \n\n \n\n if...
2
0
['Java']
0
check-if-the-number-is-fascinating
Simplest Python solution - 1,2 liner
simplest-python-solution-12-liner-by-try-z6g7
\n# Code\n\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n s = str(n)+str(2*n)+str(3*n)\n return len(s) == 9 and max(Counter(s).v
tryingall
NORMAL
2023-06-10T16:43:57.614403+00:00
2023-06-10T16:43:57.614447+00:00
540
false
\n# Code\n```\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n s = str(n)+str(2*n)+str(3*n)\n return len(s) == 9 and max(Counter(s).values()) == 1 and \'0\' not in Counter(s).keys()\n```
2
0
['Python3']
1
check-if-the-number-is-fascinating
[Python3] Solution with explanation
python3-solution-with-explanation-by-fro-6chn
We have to check if a resulting string contains unique digits except for zero. The first condition cuts off cases when there are more digits than needed: For ex
frolovdmn
NORMAL
2023-06-10T16:38:38.772440+00:00
2025-01-19T14:40:21.303610+00:00
469
false
We have to check if a resulting string contains unique digits except for zero. The first condition cuts off cases when there are more digits than needed: For example, n = 334, then we have '3346681002'. Length of this string is 10, but we should have a maximum of 9 digits. The second one is obvious, so as not to get ...
2
0
['Python', 'Python3']
0
check-if-the-number-is-fascinating
C++ | O(1) | Full Explanation | Easy Solution with comments
c-o1-full-explanation-easy-solution-with-d5i1
\n# Approach\n- Convert the input number n into a string str.\n- Compute n2 = 2 * n and n3 = 3 * n.\n- Concatenate str with the strings representing n2 and n3.\
Jeetaksh
NORMAL
2023-06-10T16:04:28.008932+00:00
2023-06-10T16:06:18.704013+00:00
374
false
\n# Approach\n- Convert the input number n into a string str.\n- Compute n2 = 2 * n and n3 = 3 * n.\n- Concatenate str with the strings representing n2 and n3.\n- Initialize an array digitCount of size 10 to keep track of the count of each digit from 0 to 9.\n- Iterate through each character in string.\n-If the charact...
2
0
['C++']
0
check-if-the-number-is-fascinating
C++ [Easy] 🔥
c-easy-by-varuntyagig-w1py
Code
varuntyagig
NORMAL
2025-02-23T07:29:47.272268+00:00
2025-02-23T07:29:47.272268+00:00
81
false
# Code ```cpp [] class Solution { public: bool isFascinating(int n) { string ans = to_string(n) + to_string(2 * n) + to_string(3 * n); for (int i = 0; i < ans.length(); ++i) { if (ans[i] == '0') { return false; } } unordered_set<char> digits;...
1
0
['Math', 'Ordered Set', 'C++']
0
check-if-the-number-is-fascinating
O(N) set
on-set-by-piramidka1989-wy4e
IntuitionApproachComplexity Time complexity: O(N) Space complexity: Code
piramidka1989
NORMAL
2025-02-16T17:19:16.722291+00:00
2025-02-16T17:19:16.722291+00:00
46
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: O(N) - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```python3 [] class Solution: def isFascinatin...
1
0
['Python3']
0
check-if-the-number-is-fascinating
Легчайшая
legchaishaia-by-danisdeveloper-65ho
Code
DanisDeveloper
NORMAL
2025-01-07T12:29:56.968074+00:00
2025-01-07T12:29:56.968074+00:00
11
false
# Code ```kotlin [] class Solution { fun isFascinating(n: Int): Boolean { if(n > 333) return false; val str = n.toString() + (2 * n).toString() + (3 * n).toString() return str.all { it != '0' } && str.toSet().size == str.length } } ```
1
0
['Kotlin']
0
check-if-the-number-is-fascinating
Easy Solution | For and dictionary | O(1) Complexity
easy-solution-for-and-dictionary-o1-comp-5f2m
IntuitionThe problem revolves around the concept of a "fascinating number." A number n is fascinating if the concatenation of n, 2n, and 3n contains all the dig
arjunravi726
NORMAL
2025-01-03T04:48:52.713568+00:00
2025-01-03T04:48:52.713568+00:00
64
false
# Intuition The problem revolves around the concept of a "fascinating number." A number n is fascinating if the concatenation of n, 2n, and 3n contains all the digits from 1 to 9 exactly once. My initial thought was to validate this by generating the concatenated string and ensuring it forms a valid permutation of the ...
1
0
['Python3']
0
check-if-the-number-is-fascinating
Efficient Java Solution
efficient-java-solution-by-abhivatsa1185-6czn
Intuition\n Describe your first thoughts on how to solve this problem. \nMy initial thought was to check if a number n is "fascinating" by verifying that the co
abhivatsa1185
NORMAL
2024-11-07T14:23:44.981471+00:00
2024-11-07T14:23:44.981498+00:00
171
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMy initial thought was to check if a number n is "fascinating" by verifying that the concatenation of n, 2\xD7n and 3 \xD7 \uD835\uDC5B contains exactly the digits 1 through 9 with no zeros or repetitions. If this combined number meets th...
1
0
['Java']
0
check-if-the-number-is-fascinating
👨🏻‍💻EASY APPROACH || Python Easy CODE ✅✅
easy-approach-python-easy-code-by-kingz_-vozf
Code\npython3 []\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n nStr = str(n) + str(2*n) + str(3*n)\n if len(nStr) != 9: \n
aryann_0101
NORMAL
2024-10-20T17:07:57.305159+00:00
2024-10-20T17:07:57.305194+00:00
16
false
# Code\n```python3 []\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n nStr = str(n) + str(2*n) + str(3*n)\n if len(nStr) != 9: \n return False\n digits = set(nStr)\n return digits == set("123456789")\n```
1
0
['String', 'Python3']
0
check-if-the-number-is-fascinating
Easy Method, Less Code:)
easy-method-less-code-by-afnanpk-amin
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
AfnanPk
NORMAL
2024-07-03T09:29:33.301533+00:00
2024-07-03T09:29:33.301560+00:00
9
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['JavaScript']
0
check-if-the-number-is-fascinating
Easy Java Solution || HashMap
easy-java-solution-hashmap-by-ravikumar5-y2zi
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
ravikumar50
NORMAL
2024-06-21T19:20:18.237979+00:00
2024-06-21T19:20:18.238006+00:00
166
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['Java']
0
check-if-the-number-is-fascinating
Simple java code 1 ms beats 96 % && 40 mb beats 78 %
simple-java-code-1-ms-beats-96-40-mb-bea-t94i
\n# Complexity\n-\n\n# Code\n\nclass Solution {\n public boolean isFascinating(int n) {\n int arr[]=new int[10];\n int temp=n;\n while(t
Arobh
NORMAL
2024-01-30T02:49:33.383417+00:00
2024-01-30T02:49:33.383445+00:00
16
false
\n# Complexity\n-\n![image.png](https://assets.leetcode.com/users/images/7250bc20-33eb-4a48-8c08-911ff4f39f24_1706582937.1476665.png)\n# Code\n```\nclass Solution {\n public boolean isFascinating(int n) {\n int arr[]=new int[10];\n int temp=n;\n while(temp>0){\n arr[temp%10]++;\n ...
1
0
['Math', 'Java']
0
check-if-the-number-is-fascinating
Simple Solution
simple-solution-by-adhilalikappil-qj4l
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
adhilalikappil
NORMAL
2024-01-19T05:07:53.289471+00:00
2024-01-19T05:07:53.289506+00:00
104
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['JavaScript']
0
check-if-the-number-is-fascinating
python3 code
python3-code-by-manasaanand1711-itwe
Intuition\nThe method multiplies the input integer n by 2 and 3, and creates a list l with the string representation of n, 2n, and 3n. It then concatenates the
manasaanand1711
NORMAL
2023-10-13T05:36:55.115663+00:00
2023-10-13T05:36:55.115688+00:00
23
false
# Intuition\nThe method multiplies the input integer n by 2 and 3, and creates a list l with the string representation of n, 2n, and 3n. It then concatenates the strings in l to form a single string m.\n\nThe method then iterates through each character in m, appends it to a list q, and converts each character in q to a...
1
0
['Python3']
0
check-if-the-number-is-fascinating
Java Set Solution
java-set-solution-by-bema3420-ycjx
\n# Code\n\nclass Solution {\n public boolean isFascinating(int n) {\n String strs = Integer.toString(n) + Integer.toString(2 * n) + Integer.toString(
bema3420
NORMAL
2023-09-16T03:59:41.372028+00:00
2023-09-16T03:59:41.372056+00:00
4
false
\n# Code\n```\nclass Solution {\n public boolean isFascinating(int n) {\n String strs = Integer.toString(n) + Integer.toString(2 * n) + Integer.toString(3 * n);\n Set<Integer> set = new HashSet<>();\n\n for (int i = 0; i < strs.length(); i++) {\n int curr = strs.charAt(i) - \'0\';\n ...
1
0
['Java']
0
check-if-the-number-is-fascinating
Using sprintf() method🧵|| functions mania😵‍💫 || but Simple!
using-sprintf-method-functions-mania-but-86jy
Intuition\nAt the starting of solve this problem, i thought i can done this problem without using any built-in functions.But it is more tideous, so that i used
Bothi_3
NORMAL
2023-08-07T09:28:33.263349+00:00
2023-08-07T09:28:33.263381+00:00
60
false
# Intuition\nAt the starting of solve this problem, i thought i can done this problem without using any built-in functions.But it is more tideous, so that i used the functions like sprintf(),strcat(),atoi().\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Calculate `two_N` and `th...
1
0
['Math', 'String', 'C']
0
check-if-the-number-is-fascinating
Worst Java Solution
worst-java-solution-by-timode-6-fcmt
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
timode-6
NORMAL
2023-07-27T12:51:55.278676+00:00
2023-07-27T12:51:55.278694+00:00
27
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(1)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $...
1
0
['Number Theory', 'Java']
0
check-if-the-number-is-fascinating
Check if The Number is Fascinating : - Time complexity: O(log(n)), Space complexity: O(1)
check-if-the-number-is-fascinating-time-v5s0l
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nCreate a HashMap to keep track of the digits encountered during the check
_Its_jUMBO_
NORMAL
2023-07-17T21:19:10.714597+00:00
2023-07-17T21:19:10.714641+00:00
452
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nCreate a HashMap to keep track of the digits encountered during the checks.\n\nCompute 2*n and 3*n.\n\nIterate through the digits of n, 2*n, and 3*n, one by one.\n\nFor each digit encountered, check if it is already present ...
1
0
['Java']
1
check-if-the-number-is-fascinating
C++ | Brute Force | Beginner Friendly | Sorting | O(n log n)
c-brute-force-beginner-friendly-sorting-2y13b
Intuition\nThe code checks if a number n is fascinating or not. To determine this, it concatenates n, 2n, and 3n into a single string and sorts it. By iterating
IshanRakte
NORMAL
2023-07-13T12:15:16.651379+00:00
2023-07-13T12:15:16.651402+00:00
32
false
**Intuition**\nThe code checks if a number n is fascinating or not. To determine this, it concatenates n, 2*n, and 3*n into a single string and sorts it. By iterating through the sorted string, if any digit is \'0\' or there are repeated digits, the number is not fascinating. Otherwise, it is considered fascinating.\n\...
1
0
['C', 'Sorting', 'C++']
1
check-if-the-number-is-fascinating
Easiest approach in Python3
easiest-approach-in-python3-by-pranjul_2-ua2b
\n\n\n# Code\n\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n m=str(n*2)\n o=str(n*3)\n p=str(n)+m+o\n k=0\n
pranjul_23
NORMAL
2023-07-12T17:31:58.808018+00:00
2023-07-12T17:31:58.808039+00:00
7
false
\n\n\n# Code\n```\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n m=str(n*2)\n o=str(n*3)\n p=str(n)+m+o\n k=0\n L=[\'1\',\'2\',\'3\',\'4\',\'5\',\'6\',\'7\',\'8\',\'9\']\n for i in range(9):\n if p[i] in L:\n k+=1\n L.r...
1
0
['Python3']
0
check-if-the-number-is-fascinating
Java solution || Using Hashset
java-solution-using-hashset-by-anishapat-q836
\n# Approach\n1.Create a string(ans) which store the resultant string after concatenate.\n2.Create a Hashset which will store elements of string uniquely later.
anishapatil1248
NORMAL
2023-07-12T12:37:53.395373+00:00
2023-07-12T12:37:53.395402+00:00
372
false
\n# Approach\n1.Create a string(ans) which store the resultant string after concatenate.\n2.Create a Hashset which will store elements of string uniquely later.\n3.Now chech if ans contains "0" if yes return false. Also check if length of ans is greater than 9 if yes return false.\n4.Now iterate in ans and check if set...
1
0
['Java']
0
check-if-the-number-is-fascinating
Count digits as we go
count-digits-as-we-go-by-fengolly-g5bv
Intuition\n Output should not have a 0\n Count digits as we make 2x and 3x of n, and look for dupes as we go\n\n# Approach\n Use an array as our map, much faste
fengolly
NORMAL
2023-07-08T19:40:17.791979+00:00
2023-07-08T19:40:17.792007+00:00
12
false
# Intuition\n* Output should not have a `0`\n* Count digits as we make 2x and 3x of n, and look for dupes as we go\n\n# Approach\n* Use an array as our map, much faster than a `map`\n* Look for `0`s\n* Count digits and look for dupes as we go\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(n)$...
1
0
['Go']
0
check-if-the-number-is-fascinating
Check if The Number is Fascinating 👨🏻‍💻👨🏻‍💻 || Java solution code 💻💻...
check-if-the-number-is-fascinating-java-fjgpe
Code\n\nclass Solution {\n public boolean isFascinating(int n) {\n int a = n*2;\n int b = n*3;\n String s = n+""+a+""+b;\n\n if(s
Jayakumar__S
NORMAL
2023-07-08T18:13:46.118339+00:00
2023-07-08T18:13:46.118359+00:00
410
false
# Code\n```\nclass Solution {\n public boolean isFascinating(int n) {\n int a = n*2;\n int b = n*3;\n String s = n+""+a+""+b;\n\n if(s.length() < 8){\n return false;\n }\n for(int i=0; i<s.length(); i++){\n if(s.charAt(i) == \'0\'){\n ret...
1
0
['Java']
0
check-if-the-number-is-fascinating
Beats 100% C++
beats-100-c-by-antony_ft-of9v
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
antony_ft
NORMAL
2023-07-07T12:28:24.999579+00:00
2023-07-07T12:28:24.999603+00:00
10
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['C++']
0
check-if-the-number-is-fascinating
Beats 100% C++
beats-100-c-by-antony_ft-00pt
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
antony_ft
NORMAL
2023-07-07T12:28:11.850091+00:00
2023-07-07T12:28:11.850115+00:00
8
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['C++']
0
check-if-the-number-is-fascinating
✅✅Easy Solution Using Set ✅✅
easy-solution-using-set-by-vinit250000-ycn2
\n\n void check(int n,string& temp)\n {\n while(n!=0)\n {\n temp.push_back((n%10)+\'0\');\n n=n/10;\n }\n }
vinit250000
NORMAL
2023-06-29T06:55:33.256178+00:00
2023-06-29T06:55:33.256208+00:00
74
false
```\n\n void check(int n,string& temp)\n {\n while(n!=0)\n {\n temp.push_back((n%10)+\'0\');\n n=n/10;\n }\n }\n \n bool isFascinating(int n) \n {\n string temp;\n set<int> s;\n int num=n;\n \n check(num,temp);\n \n ...
1
0
[]
0
check-if-the-number-is-fascinating
[C++] Simplest Solution using frequency.
c-simplest-solution-using-frequency-by-i-rwfr
Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n bool isFascinating(int n) {\n\n if(n >= 334
Irfan_gouri
NORMAL
2023-06-24T12:39:26.523120+00:00
2023-06-24T12:39:26.523148+00:00
54
false
# Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n bool isFascinating(int n) {\n\n if(n >= 334) return false;\n\n vector<int> freq(10, 0);\n\n string temp = to_string(n);\n n = 2 * n;\n temp += to_string(n);\n n = ...
1
0
['Hash Table', 'Math', 'C++']
0
check-if-the-number-is-fascinating
100% FAST Simple Solution
100-fast-simple-solution-by-bekki3-z44u
Intuition\nThere are few such number between 100-999\n\n# Code\n\nclass Solution {\npublic:\n bool isFascinating(int n) {\n if(n==192){\n r
bekki3
NORMAL
2023-06-20T13:44:15.796713+00:00
2023-06-20T13:44:15.796740+00:00
245
false
# Intuition\nThere are few such number between 100-999\n\n# Code\n```\nclass Solution {\npublic:\n bool isFascinating(int n) {\n if(n==192){\n return true;\n }\n else if(n==273){\n return true;\n }\n else if(n==327){\n return true; \n }\n ...
1
0
['Math', 'C++', 'Java', 'Python3', 'JavaScript']
0
check-if-the-number-is-fascinating
Python3 ✅✅✅ || easy and fast || 5 lines
python3-easy-and-fast-5-lines-by-blackho-uvyb
Code\n\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n num = str(n)\n num += str(2 * n)\n num += str(3 * n)\n count
Little_Tiub
NORMAL
2023-06-19T04:27:29.969303+00:00
2023-06-19T04:27:29.969321+00:00
13
false
# Code\n```\nclass Solution:\n def isFascinating(self, n: int) -> bool:\n num = str(n)\n num += str(2 * n)\n num += str(3 * n)\n counts = [num.count(x) for x in num]\n return "0" not in num and counts.count(1) == len(counts)\n```\n![image.png](https://assets.leetcode.com/users/imag...
1
0
['Python3']
0
check-if-the-number-is-fascinating
Java Easy to Understand Solution
java-easy-to-understand-solution-by-brot-p2qp
\nclass Solution {\n public boolean isFascinating(int n) {\n if (Math.floor(Math.log(n) + 1) < 3)\n\t\t\t\t\treturn false; // false if the number is n
brothercode
NORMAL
2023-06-18T14:03:20.573821+00:00
2023-06-18T14:03:20.573844+00:00
68
false
```\nclass Solution {\n public boolean isFascinating(int n) {\n if (Math.floor(Math.log(n) + 1) < 3)\n\t\t\t\t\treturn false; // false if the number is not a 3 digit number\n String str = String.valueOf(n) + String.valueOf(2 * n) + String.valueOf(3 * n); // concatenate the results.\n char ch1[] ...
1
0
['Java']
0
check-if-the-number-is-fascinating
C# Linq OneLiner
c-linq-oneliner-by-7bnx-dirh
\n\npublic class Solution {\n public bool IsFascinating(int n)\n => $"{n}{n*2}{n*3}".OrderBy(x => x).SequenceEqual("123456789");\n}\n
7bnx
NORMAL
2023-06-17T20:53:43.570384+00:00
2023-06-17T20:53:43.570403+00:00
45
false
\n```\npublic class Solution {\n public bool IsFascinating(int n)\n => $"{n}{n*2}{n*3}".OrderBy(x => x).SequenceEqual("123456789");\n}\n```
1
0
['C#']
0
check-if-the-number-is-fascinating
JAVA | Simple solution | No String | 100% Faster
java-simple-solution-no-string-100-faste-kb8p
Complexity\n- Time complexity: O(log(n))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\
ilyastuit
NORMAL
2023-06-12T05:49:16.015407+00:00
2023-06-22T05:46:31.050764+00:00
735
false
# Complexity\n- Time complexity: $$O(log(n))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n\n public boolean isFascinating(int n) {\n boolean[] facinatingDigits = new boolean[10...
1
0
['Math', 'Java']
2
check-if-the-number-is-fascinating
Super Easy C++ Solution
super-easy-c-solution-by-lotus18-dpj4
Code\n\nclass Solution \n{\npublic:\n bool isFascinating(int n) \n {\n int n2=2*n;\n int n3=3*n;\n string s=to_string(n)+to_string(n2
lotus18
NORMAL
2023-06-11T13:51:36.334974+00:00
2023-06-11T13:51:36.335016+00:00
111
false
# Code\n```\nclass Solution \n{\npublic:\n bool isFascinating(int n) \n {\n int n2=2*n;\n int n3=3*n;\n string s=to_string(n)+to_string(n2)+to_string(n3);\n set<char> st;\n for(auto ch: s) \n {\n if(ch==\'0\') return false;\n st.insert(ch);\n ...
1
0
['C++']
0
check-if-the-number-is-fascinating
Video Solution || Accepted✅✅
video-solution-accepted-by-sanjeev_pu-3ih2
Intuition\n Describe your first thoughts on how to solve this problem. \nsorting will be the hero\n\n# Approach\n Describe your approach to solving the problem.
Sanjeev_PU
NORMAL
2023-06-10T21:14:18.460021+00:00
2023-06-10T21:14:18.460065+00:00
367
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nsorting will be the hero\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1) fimd the actual number after computation in string form\n2) sort the string\n3) check the duplicate or zero value \n\nclick to see the vid...
1
0
['C++']
0
check-if-the-number-is-fascinating
✅ Simple | Beginners friendly | C++ Solution 🚀
simple-beginners-friendly-c-solution-by-b9eyl
\nclass Solution {\npublic:\n bool isFascinating(int n) {\n \n string s1 = to_string(n);\n string s2 = to_string(2*n);\n string s
aryan1shrivastava
NORMAL
2023-06-10T20:18:30.408533+00:00
2023-06-10T20:18:30.408574+00:00
61
false
```\nclass Solution {\npublic:\n bool isFascinating(int n) {\n \n string s1 = to_string(n);\n string s2 = to_string(2*n);\n string s3 = to_string(3*n);\n \n string s = s1 + s2 + s3;\n \n unordered_map<char, int> mp;\n \n for(auto c: s){\n ...
1
0
['String', 'C']
1
check-if-the-number-is-fascinating
java easy solution for beginner
java-easy-solution-for-beginner-by-jatin-639v
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Jatin_mohan_gupta
NORMAL
2023-06-10T17:45:00.925065+00:00
2023-06-10T17:45:00.925110+00:00
64
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['Java']
0